authen-express 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +8 -8
package/package.json
CHANGED
package/src/index.ts
CHANGED
@@ -21,15 +21,15 @@ export interface Privilege {
|
|
21
21
|
children?: Privilege[];
|
22
22
|
permissions?: number;
|
23
23
|
}
|
24
|
-
export interface AuthResult {
|
24
|
+
export interface AuthResult<ID> {
|
25
25
|
status: number | string;
|
26
|
-
user?: UserAccount
|
26
|
+
user?: UserAccount<ID>;
|
27
27
|
message?: string;
|
28
28
|
}
|
29
|
-
export type Result = AuthResult
|
30
|
-
export type LoginResult = AuthResult
|
31
|
-
export interface UserAccount {
|
32
|
-
id?:
|
29
|
+
export type Result<ID> = AuthResult<ID>;
|
30
|
+
export type LoginResult<ID> = AuthResult<ID>;
|
31
|
+
export interface UserAccount<ID> {
|
32
|
+
id?: ID;
|
33
33
|
username?: string;
|
34
34
|
contact?: string;
|
35
35
|
email?: string;
|
@@ -48,8 +48,8 @@ export interface UserAccount {
|
|
48
48
|
gender?: string;
|
49
49
|
imageURL?: string;
|
50
50
|
}
|
51
|
-
export class AuthenticationController<T extends User> {
|
52
|
-
constructor (public log: Log, public login: (user: T) => Promise<AuthResult
|
51
|
+
export class AuthenticationController<T extends User, ID> {
|
52
|
+
constructor (public log: Log, public login: (user: T) => Promise<AuthResult<ID>>, public cookie?: boolean, public decrypt?: (cipherText: string) => string|undefined) {
|
53
53
|
this.authenticate = this.authenticate.bind(this);
|
54
54
|
}
|
55
55
|
authenticate(req: Request, res: Response) {
|