mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-01 23:58:58 -04:00
feat: consolidate entities create
This was done to give better typings to the function signatures of entities `create` methods. It also ensures that each field that should be set to `null` is set to `null` and doesn't leave that up to the typeorm handlers. See: #1641 Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
bd902e50d1
commit
d0b8e4cd36
14 changed files with 89 additions and 40 deletions
|
@ -45,21 +45,17 @@ export class AuthToken {
|
|||
lastUsed: Date | null;
|
||||
|
||||
public static create(
|
||||
keyId: string,
|
||||
user: User,
|
||||
label: string,
|
||||
keyId: string,
|
||||
accessToken: string,
|
||||
validUntil: Date,
|
||||
): Pick<
|
||||
AuthToken,
|
||||
'user' | 'label' | 'keyId' | 'accessTokenHash' | 'createdAt' | 'validUntil'
|
||||
> {
|
||||
): Omit<AuthToken, 'id' | 'createdAt'> {
|
||||
const newToken = new AuthToken();
|
||||
newToken.keyId = keyId;
|
||||
newToken.user = user;
|
||||
newToken.label = label;
|
||||
newToken.keyId = keyId;
|
||||
newToken.accessTokenHash = accessToken;
|
||||
newToken.createdAt = new Date();
|
||||
newToken.validUntil = validUntil;
|
||||
newToken.lastUsed = null;
|
||||
return newToken;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue