@@ -1,6 +1,7 @@
|
||||
import { IsBoolean, IsEmail, IsInt, IsNotEmpty, IsOptional, IsString, IsUUID } from 'class-validator';
|
||||
import * as jsonwebtoken from "jsonwebtoken";
|
||||
import { config } from './config';
|
||||
import { Runner } from './models/entities/Runner';
|
||||
import { User } from './models/entities/User';
|
||||
|
||||
/**
|
||||
@@ -34,6 +35,19 @@ export class JwtCreator {
|
||||
}, config.jwt_secret)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new selfservice token for a given runner.
|
||||
* @param runner Runner entity that the access token shall be created for.
|
||||
* @param expiry_timestamp Timestamp for the token expiry. Will be set about 9999 years if none provided.
|
||||
*/
|
||||
public static createSelfService(runner: Runner, expiry_timestamp?: number) {
|
||||
if (!expiry_timestamp) { expiry_timestamp = Math.floor(Date.now() / 1000) + 36000 * 60 * 24 * 365 * 9999; }
|
||||
return jsonwebtoken.sign({
|
||||
id: runner.id,
|
||||
exp: expiry_timestamp
|
||||
}, config.jwt_secret)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new password reset token for a given user.
|
||||
* The token is valid for 15 minutes or 1 use - whatever comes first.
|
||||
|
||||
Reference in New Issue
Block a user