mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
Merge branch 'master' of github.com:gradido/gradido into 1881-set-role-in-admin-interface
This commit is contained in:
commit
4e0a2f42a6
@ -10,7 +10,7 @@ Decimal.set({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const constants = {
|
const constants = {
|
||||||
DB_VERSION: '0036-unique_previous_in_transactions',
|
DB_VERSION: '0037-drop_server_user_table',
|
||||||
DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
|
DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
|
||||||
LOG4JS_CONFIG: 'log4js-config.json',
|
LOG4JS_CONFIG: 'log4js-config.json',
|
||||||
// default log level on production should be info
|
// default log level on production should be info
|
||||||
|
|||||||
@ -1,25 +0,0 @@
|
|||||||
import { EntityRepository, Repository } from '@dbTools/typeorm'
|
|
||||||
import { UserSetting } from '@entity/UserSetting'
|
|
||||||
import { isStringBoolean } from '@/util/validate'
|
|
||||||
|
|
||||||
@EntityRepository(UserSetting)
|
|
||||||
export class UserSettingRepository extends Repository<UserSetting> {
|
|
||||||
async setOrUpdate(userId: number, value: string): Promise<UserSetting> {
|
|
||||||
let entity = await this.findOne({ userId: userId })
|
|
||||||
|
|
||||||
if (!entity) {
|
|
||||||
entity = new UserSetting()
|
|
||||||
entity.userId = userId
|
|
||||||
}
|
|
||||||
entity.value = value
|
|
||||||
return this.save(entity)
|
|
||||||
}
|
|
||||||
|
|
||||||
async readBoolean(userId: number): Promise<boolean> {
|
|
||||||
const entity = await this.findOne({ userId: userId })
|
|
||||||
if (!entity || !isStringBoolean(entity.value)) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return entity.value.toLowerCase() === 'true'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -20,7 +20,6 @@ const communityDbUser: dbUser = {
|
|||||||
isAdmin: null,
|
isAdmin: null,
|
||||||
publisherId: 0,
|
publisherId: 0,
|
||||||
passphrase: '',
|
passphrase: '',
|
||||||
settings: [],
|
|
||||||
hasId: function (): boolean {
|
hasId: function (): boolean {
|
||||||
throw new Error('Function not implemented.')
|
throw new Error('Function not implemented.')
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,32 +1,39 @@
|
|||||||
# database
|
# database
|
||||||
|
|
||||||
## Project setup
|
## Project setup
|
||||||
```
|
|
||||||
|
```bash
|
||||||
yarn install
|
yarn install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Upgrade migrations production
|
## Upgrade migrations production
|
||||||
```
|
|
||||||
|
```bash
|
||||||
yarn up
|
yarn up
|
||||||
```
|
```
|
||||||
|
|
||||||
## Upgrade migrations development
|
## Upgrade migrations development
|
||||||
```
|
|
||||||
|
```bash
|
||||||
yarn dev_up
|
yarn dev_up
|
||||||
```
|
```
|
||||||
|
|
||||||
## Downgrade migrations production
|
## Downgrade migrations production
|
||||||
```
|
|
||||||
|
```bash
|
||||||
yarn down
|
yarn down
|
||||||
```
|
```
|
||||||
|
|
||||||
## Downgrade migrations development
|
## Downgrade migrations development
|
||||||
```
|
|
||||||
|
```bash
|
||||||
yarn dev_down
|
yarn dev_down
|
||||||
```
|
```
|
||||||
|
|
||||||
## Reset database
|
## Reset database
|
||||||
```
|
|
||||||
|
```bash
|
||||||
yarn dev_reset
|
yarn dev_reset
|
||||||
```
|
```
|
||||||
|
|
||||||
Runs all down migrations and after this all up migrations.
|
Runs all down migrations and after this all up migrations.
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm'
|
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm'
|
||||||
import { UserSetting } from '../UserSetting'
|
import { UserSetting } from '../0002-add_settings/UserSetting'
|
||||||
|
|
||||||
// Moriz: I do not like the idea of having two user tables
|
// Moriz: I do not like the idea of having two user tables
|
||||||
@Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
@Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm'
|
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm'
|
||||||
import { User } from '../User'
|
import { User } from '../0034-drop_server_user_table/User'
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class UserSetting extends BaseEntity {
|
export class UserSetting extends BaseEntity {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm'
|
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm'
|
||||||
import { UserSetting } from '../UserSetting'
|
import { UserSetting } from '../0002-add_settings/UserSetting'
|
||||||
|
|
||||||
@Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
@Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
||||||
export class User extends BaseEntity {
|
export class User extends BaseEntity {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm'
|
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm'
|
||||||
import { UserSetting } from '../UserSetting'
|
import { UserSetting } from '../0002-add_settings/UserSetting'
|
||||||
|
|
||||||
@Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
@Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
||||||
export class User extends BaseEntity {
|
export class User extends BaseEntity {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm'
|
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm'
|
||||||
import { UserSetting } from '../UserSetting'
|
import { UserSetting } from '../0002-add_settings/UserSetting'
|
||||||
|
|
||||||
@Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
@Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
||||||
export class User extends BaseEntity {
|
export class User extends BaseEntity {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm'
|
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm'
|
||||||
import { UserSetting } from '../UserSetting'
|
import { UserSetting } from '../0002-add_settings/UserSetting'
|
||||||
|
|
||||||
@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
||||||
export class User extends BaseEntity {
|
export class User extends BaseEntity {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import {
|
|||||||
OneToMany,
|
OneToMany,
|
||||||
DeleteDateColumn,
|
DeleteDateColumn,
|
||||||
} from 'typeorm'
|
} from 'typeorm'
|
||||||
import { UserSetting } from '../UserSetting'
|
import { UserSetting } from '../0002-add_settings/UserSetting'
|
||||||
|
|
||||||
@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
||||||
export class User extends BaseEntity {
|
export class User extends BaseEntity {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import {
|
|||||||
OneToMany,
|
OneToMany,
|
||||||
DeleteDateColumn,
|
DeleteDateColumn,
|
||||||
} from 'typeorm'
|
} from 'typeorm'
|
||||||
import { UserSetting } from '../UserSetting'
|
import { UserSetting } from '../0002-add_settings/UserSetting'
|
||||||
|
|
||||||
@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
||||||
export class User extends BaseEntity {
|
export class User extends BaseEntity {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import {
|
|||||||
OneToMany,
|
OneToMany,
|
||||||
DeleteDateColumn,
|
DeleteDateColumn,
|
||||||
} from 'typeorm'
|
} from 'typeorm'
|
||||||
import { UserSetting } from '../UserSetting'
|
import { UserSetting } from '../0002-add_settings/UserSetting'
|
||||||
|
|
||||||
@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
||||||
export class User extends BaseEntity {
|
export class User extends BaseEntity {
|
||||||
|
|||||||
70
database/entity/0037-drop_server_user_table/User.ts
Normal file
70
database/entity/0037-drop_server_user_table/User.ts
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, DeleteDateColumn } from 'typeorm'
|
||||||
|
|
||||||
|
@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
|
||||||
|
export class User extends BaseEntity {
|
||||||
|
@PrimaryGeneratedColumn('increment', { unsigned: true })
|
||||||
|
id: number
|
||||||
|
|
||||||
|
@Column({ name: 'public_key', type: 'binary', length: 32, default: null, nullable: true })
|
||||||
|
pubKey: Buffer
|
||||||
|
|
||||||
|
@Column({ name: 'privkey', type: 'binary', length: 80, default: null, nullable: true })
|
||||||
|
privKey: Buffer
|
||||||
|
|
||||||
|
@Column({ length: 255, unique: true, nullable: false, collation: 'utf8mb4_unicode_ci' })
|
||||||
|
email: string
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
name: 'first_name',
|
||||||
|
length: 255,
|
||||||
|
nullable: true,
|
||||||
|
default: null,
|
||||||
|
collation: 'utf8mb4_unicode_ci',
|
||||||
|
})
|
||||||
|
firstName: string
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
name: 'last_name',
|
||||||
|
length: 255,
|
||||||
|
nullable: true,
|
||||||
|
default: null,
|
||||||
|
collation: 'utf8mb4_unicode_ci',
|
||||||
|
})
|
||||||
|
lastName: string
|
||||||
|
|
||||||
|
@DeleteDateColumn()
|
||||||
|
deletedAt: Date | null
|
||||||
|
|
||||||
|
@Column({ type: 'bigint', default: 0, unsigned: true })
|
||||||
|
password: BigInt
|
||||||
|
|
||||||
|
@Column({ name: 'email_hash', type: 'binary', length: 32, default: null, nullable: true })
|
||||||
|
emailHash: Buffer
|
||||||
|
|
||||||
|
@Column({ name: 'created', default: () => 'CURRENT_TIMESTAMP', nullable: false })
|
||||||
|
createdAt: Date
|
||||||
|
|
||||||
|
@Column({ name: 'email_checked', type: 'bool', nullable: false, default: false })
|
||||||
|
emailChecked: boolean
|
||||||
|
|
||||||
|
@Column({ length: 4, default: 'de', collation: 'utf8mb4_unicode_ci', nullable: false })
|
||||||
|
language: string
|
||||||
|
|
||||||
|
@Column({ name: 'is_admin', type: 'datetime', nullable: true, default: null })
|
||||||
|
isAdmin: Date | null
|
||||||
|
|
||||||
|
@Column({ name: 'referrer_id', type: 'int', unsigned: true, nullable: true, default: null })
|
||||||
|
referrerId?: number | null
|
||||||
|
|
||||||
|
@Column({ name: 'publisher_id', default: 0 })
|
||||||
|
publisherId: number
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: 'text',
|
||||||
|
name: 'passphrase',
|
||||||
|
collation: 'utf8mb4_unicode_ci',
|
||||||
|
nullable: true,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
passphrase: string
|
||||||
|
}
|
||||||
@ -1 +1 @@
|
|||||||
export { User } from './0034-drop_server_user_table/User'
|
export { User } from './0037-drop_server_user_table/User'
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
export { UserSetting } from './0002-add_settings/UserSetting'
|
|
||||||
@ -4,7 +4,6 @@ import { Migration } from './Migration'
|
|||||||
import { Transaction } from './Transaction'
|
import { Transaction } from './Transaction'
|
||||||
import { TransactionLink } from './TransactionLink'
|
import { TransactionLink } from './TransactionLink'
|
||||||
import { User } from './User'
|
import { User } from './User'
|
||||||
import { UserSetting } from './UserSetting'
|
|
||||||
import { AdminPendingCreation } from './AdminPendingCreation'
|
import { AdminPendingCreation } from './AdminPendingCreation'
|
||||||
|
|
||||||
export const entities = [
|
export const entities = [
|
||||||
@ -15,5 +14,4 @@ export const entities = [
|
|||||||
Transaction,
|
Transaction,
|
||||||
TransactionLink,
|
TransactionLink,
|
||||||
User,
|
User,
|
||||||
UserSetting,
|
|
||||||
]
|
]
|
||||||
|
|||||||
19
database/migrations/0037-drop_server_user_table.ts
Normal file
19
database/migrations/0037-drop_server_user_table.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/* MIGRATION DROP user_setting TABLE */
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
|
||||||
|
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||||
|
await queryFn('DROP TABLE `user_setting`;')
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||||
|
await queryFn(`
|
||||||
|
CREATE TABLE IF NOT EXISTS \`user_setting\` (
|
||||||
|
\`id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
\`userId\` int(11) NOT NULL,
|
||||||
|
\`key\` varchar(255) NOT NULL,
|
||||||
|
\`value\` varchar(255) NOT NULL,
|
||||||
|
PRIMARY KEY (\`id\`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`)
|
||||||
|
}
|
||||||
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
<b-collapse id="nav-collapse" is-nav class="mt-5 mt-lg-0">
|
<b-collapse id="nav-collapse" is-nav class="mt-5 mt-lg-0">
|
||||||
<b-navbar-nav class="ml-auto" right>
|
<b-navbar-nav class="ml-auto" right>
|
||||||
<b-nav-item href="https://gradido.net/de/" target="_blank">
|
<b-nav-item :href="`https://gradido.net/${$i18n.locale}`" target="_blank">
|
||||||
{{ $t('auth.navbar.aboutGradido') }}
|
{{ $t('auth.navbar.aboutGradido') }}
|
||||||
</b-nav-item>
|
</b-nav-item>
|
||||||
<b-nav-item to="/register" class="authNavbar ml-lg-5">{{ $t('signup') }}</b-nav-item>
|
<b-nav-item to="/register" class="authNavbar ml-lg-5">{{ $t('signup') }}</b-nav-item>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user