mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-02 07:59:56 -04:00
private: Add until to token creation
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
324ba71d24
commit
4784a1aea2
3 changed files with 20 additions and 8 deletions
|
@ -6,7 +6,6 @@
|
|||
|
||||
import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { User } from './user.entity';
|
||||
import { Type } from 'class-transformer';
|
||||
|
||||
@Entity()
|
||||
export class AuthToken {
|
||||
|
@ -25,16 +24,21 @@ export class AuthToken {
|
|||
@Column({ unique: true })
|
||||
accessToken: string;
|
||||
|
||||
@Column({ type: 'date' })
|
||||
validUntil: Date;
|
||||
|
||||
public static create(
|
||||
user: User,
|
||||
identifier: string,
|
||||
accessToken: string,
|
||||
validUntil: Date,
|
||||
): Pick<AuthToken, 'user' | 'accessToken'> {
|
||||
const newToken = new AuthToken();
|
||||
newToken.user = user;
|
||||
newToken.identifier = identifier;
|
||||
newToken.accessToken = accessToken;
|
||||
newToken.createdAt = new Date();
|
||||
newToken.validUntil = validUntil;
|
||||
return newToken;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue