# Class User

User

#### Hierarchy

- User

#### Indexable

[key: string]: any

- Defined in saltcorn-data/models/user.ts:71

#####
Index

### Constructors

constructor

### Properties

_attributes
api_token?
disabled
email
id?
language?
last_mobile_login?
password
reset_password_expiry?
reset_password_token?
role_id
verification_token?
verified_on?

### Accessors

session_object
table

### Methods

auth_method_allowed
changePasswordTo
checkPassword
delete
destroy_sessions
getNewAPIToken
getNewResetToken
relogin
removeAPIToken
send_verification_email
set_language
set_to_verified
update
updateLastMobileLogin
authenticate
count
create
destroy_all_tenant_sessions
find
findForSession
findOne
findOrCreateByAttribute
generate_password
get_roles
hashPassword
matches_existing_user
nonEmpty
resetPasswordWithToken
unacceptable_password_reason
valid_email
verifyWithToken

## Constructors

### constructor

- new User(o): User

- User constructor

  #### Parameters

  - ##### o: User | UserCfg

  #### Returns User

  - Defined in saltcorn-data/models/user.ts:91

## Properties

### _attributes

_attributes: GenObj

- Defined in saltcorn-data/models/user.ts:75

### `Optional` api_token

api_token?: null | string

- Defined in saltcorn-data/models/user.ts:76

### disabled

disabled: boolean

- Defined in saltcorn-data/models/user.ts:79

### email

email: string

- Defined in saltcorn-data/models/user.ts:72

### `Optional` id

id?: number

- Defined in saltcorn-data/models/user.ts:80

### `Optional` language

language?: string

- Defined in saltcorn-data/models/user.ts:74

### `Optional` last_mobile_login

last_mobile_login?: null | Date

- Defined in saltcorn-data/models/user.ts:84

### password

password: string

- Defined in saltcorn-data/models/user.ts:73

### `Optional` reset_password_expiry

reset_password_expiry?: null | Date

- Defined in saltcorn-data/models/user.ts:82

### `Optional` reset_password_token

reset_password_token?: null | string

- Defined in saltcorn-data/models/user.ts:81

### role_id

role_id: number

- Defined in saltcorn-data/models/user.ts:83

### `Optional` verification_token

verification_token?: string

- Defined in saltcorn-data/models/user.ts:77

### `Optional` verified_on

verified_on?: Date

- Defined in saltcorn-data/models/user.ts:78

## Accessors

### session_object

- get session_object(): any

- Create session object for user

  #### Returns any

  - Defined in saltcorn-data/models/user.ts:259

### `Static` table

- get table(): Table

- #### Returns Table

  - Defined in saltcorn-data/models/user.ts:281

## Methods

### auth_method_allowed

- auth_method_allowed(method_name): boolean

- #### Parameters

  - ##### method_name: string

  #### Returns boolean

  - Defined in saltcorn-data/models/user.ts:302

### changePasswordTo

- changePasswordTo(newpw, expireToken?): Promise<void>

- Change password

  #### Parameters

  - ##### newpw: string

    new password string

  - ##### `Optional` expireToken: boolean

    if true than force reset password token

  #### Returns Promise<void>

  no result

  - Defined in saltcorn-data/models/user.ts:138

### checkPassword

- checkPassword(pw): boolean

- Check password

  #### Parameters

  - ##### pw: string

    password string

  #### Returns boolean

  - Defined in saltcorn-data/models/user.ts:128

### delete

- delete(): Promise<void>

- Delete user based on session object

  #### Returns Promise<void>

  - Defined in saltcorn-data/models/user.ts:425

### destroy_sessions

- destroy_sessions(): Promise<void>

- #### Returns Promise<void>

  - Defined in saltcorn-data/models/user.ts:635

### getNewAPIToken

- getNewAPIToken(): Promise<string>

- Add new API token to user

  #### Returns Promise<string>

  - Defined in saltcorn-data/models/user.ts:484

### getNewResetToken

- getNewResetToken(): Promise<string>

- Get new reset token

  #### Returns Promise<string>

  - Defined in saltcorn-data/models/user.ts:471

### relogin

- relogin(req): Promise<void>

- #### Parameters

  - ##### req: any

  #### Returns Promise<void>

  - Defined in saltcorn-data/models/user.ts:663

### removeAPIToken

- removeAPIToken(): Promise<null>

- Remove API token for user

  #### Returns Promise<null>

  - Defined in saltcorn-data/models/user.ts:495

### send_verification_email

- send_verification_email(req?, opts?): Promise<any>

- #### Parameters

  - ##### `Optional` req: any

  - ##### `Optional` opts: {
    new_verification_token?: string;
    }

    - ##### `Optional` new_verification_token?: string

  #### Returns Promise<any>

  - Defined in saltcorn-data/models/user.ts:310

### set_language

- set_language(language): Promise<void>

- Set language for User in database

  #### Parameters

  - ##### language: string

  #### Returns Promise<void>

  - Defined in saltcorn-data/models/user.ts:442

### set_to_verified

- set_to_verified(): Promise<true>

- #### Returns Promise<true>

  - Defined in saltcorn-data/models/user.ts:545

### update

- update(row, plainPassword?): Promise<void>

- Update User

  #### Parameters

  - ##### row: Partial<User>

  - ##### `Optional` plainPassword: string

  #### Returns Promise<void>

  - Defined in saltcorn-data/models/user.ts:451

### updateLastMobileLogin

- updateLastMobileLogin(date): Promise<void>

- update 'last_mobile_login' columnwill

  #### Parameters

  - ##### date: null | Date

    new login_date or null for logout (invalidates all jwts)

  #### Returns Promise<void>

  - Defined in saltcorn-data/models/user.ts:676

### `Static` authenticate

- authenticate(uo): Promise<false | User>

- Authenticate User

  #### Parameters

  - ##### uo: any

    user object

  #### Returns Promise<false | User>

  - Defined in saltcorn-data/models/user.ts:290

### `Static` count

- count(where?): Promise<number>

- Count users in database

  #### Parameters

  - ##### `Optional` where: Where

  #### Returns Promise<number>

  - Defined in saltcorn-data/models/user.ts:609

### `Static` create

- create(uo): Promise<User | ErrorMessage>

- Create user

  #### Parameters

  - ##### uo: GenObj

    user object

  #### Returns Promise<User | ErrorMessage>

  - Defined in saltcorn-data/models/user.ts:189

### `Static` destroy_all_tenant_sessions

- destroy_all_tenant_sessions(tenant?): Promise<void>

- #### Parameters

  - ##### `Optional` tenant: string

  #### Returns Promise<void>

  - Defined in saltcorn-data/models/user.ts:648

### `Static` find

- find(where, selectopts?): Promise<User[]>

- Find users list

  #### Parameters

  - ##### where: Where

    where object

  - ##### `Optional` selectopts: SelectOptions

    select options

  #### Returns Promise<User[]>

  - Defined in saltcorn-data/models/user.ts:393

### `Static` findForSession

- findForSession(where): Promise<false | User>

- Find users list

  #### Parameters

  - ##### where: Where

    where object

  #### Returns Promise<false | User>

  - Defined in saltcorn-data/models/user.ts:323

### `Static` findOne

- findOne(where): Promise<undefined | User>

- Find one user

  #### Parameters

  - ##### where: Where

    where object

  #### Returns Promise<undefined | User>

  - Defined in saltcorn-data/models/user.ts:406

### `Static` findOrCreateByAttribute

- findOrCreateByAttribute(k, v, uo?): Promise<false | User | ErrorMessage>

- Find or Create User

  #### Parameters

  - ##### k: string

  - ##### v: any

  - ##### `Optional` uo: any = {}

  #### Returns Promise<false | User | ErrorMessage>

  - Defined in saltcorn-data/models/user.ts:156

### `Static` generate_password

- generate_password(): string

- Generate password

  #### Returns string

  - Defined in saltcorn-data/models/user.ts:625

### `Static` get_roles

- get_roles(): Promise<Row[]>

- Get available roles

  #### Returns Promise<Row[]>

  - Defined in saltcorn-data/models/user.ts:617

### `Static` hashPassword

- hashPassword(pw): Promise<string>

- Get bcrypt hash for Password

  #### Parameters

  - ##### pw: string

    password string

  #### Returns Promise<string>

  - Defined in saltcorn-data/models/user.ts:119

### `Static` matches_existing_user

- matches_existing_user(uo): Promise<boolean>

- #### Parameters

  - ##### uo: any

  #### Returns Promise<boolean>

  - Defined in saltcorn-data/models/user.ts:242

### `Static` nonEmpty

- nonEmpty(): Promise<boolean>

- Check that user table is not empty in database

  #### Returns Promise<boolean>

  true if there are users in db

  #### Deprecated

  use method count()

  - Defined in saltcorn-data/models/user.ts:416

### `Static` resetPasswordWithToken

- resetPasswordWithToken(__namedParameters): Promise<ErrorMessage | SuccessMessage>

- Reset password using token

  #### Parameters

  - ##### __namedParameters: {
    email: string;
    password: string;
    reset_password_token: string;
    }

    - ##### email: string

    - ##### password: string

    - ##### reset_password_token: string

  #### Returns Promise<ErrorMessage | SuccessMessage>

  - Defined in saltcorn-data/models/user.ts:566

### `Static` unacceptable_password_reason

- unacceptable_password_reason(pw): undefined | string

- Validate password

  #### Parameters

  - ##### pw: string

  #### Returns undefined | string

  - Defined in saltcorn-data/models/user.ts:507

### `Static` valid_email

- valid_email(email): boolean

- Validate email

  #### Parameters

  - ##### email: string

  #### Returns boolean

  - Defined in saltcorn-data/models/user.ts:518

### `Static` verifyWithToken

- verifyWithToken(__namedParameters): Promise<true | ErrorMessage>

- Verification with token

  #### Parameters

  - ##### __namedParameters: {
    email: string;
    verification_token: string;
    }

    - ##### email: string

    - ##### verification_token: string

  #### Returns Promise<true | ErrorMessage>

  true if verification passed, error string if not

  - Defined in saltcorn-data/models/user.ts:528

Generated using TypeDoc