Skip to content

Commit

Permalink
feat(core): support user.createdAt
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed May 14, 2023
1 parent e129f37 commit ad760bf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/core/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface User {
authority: number
name: string
locale: string
createdAt: Date
}

export namespace User {
Expand Down Expand Up @@ -82,6 +83,7 @@ export class DatabaseService extends Database<Tables> {
flag: 'unsigned(20)',
authority: 'unsigned(4)',
locale: 'string(63)',
createdAt: 'timestamp',
}, {
autoInc: true,
})
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ extend(Session.prototype as Session.Private, {
if (user) return user
const authority = await this.resolve(app.config.autoAuthorize)
if (authority) {
return app.database.createUser(platform, id, { authority })
return app.database.createUser(platform, id, { authority, createdAt: new Date() })
} else {
const user = app.model.tables.user.create()
Object.assign(user, { [platform]: id, authority, $detached: true })
Expand Down

0 comments on commit ad760bf

Please sign in to comment.