Skip to content

Commit aa5d1ed

Browse files
committed
Enhance token creation by including 'token' field in identity payload
1 parent bd3acb5 commit aa5d1ed

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/core/auth/auth.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { resolve } from 'path';
1515
import { existsSync, readFileSync, writeFileSync } from 'fs';
1616
import { ConsoleSession } from '~/_common/data/console-session';
1717
import { KeyringsService } from '../keyrings/keyrings.service';
18+
import { ApiSession } from '~/_common/data/api-session';
1819

1920
@Injectable()
2021
export class AuthService extends AbstractService implements OnModuleInit {
@@ -116,7 +117,7 @@ export class AuthService extends AbstractService implements OnModuleInit {
116117
}
117118

118119
public async createTokens(
119-
identity: AgentType,
120+
identity: AgentType & ApiSession,
120121
refresh_token?: string | false,
121122
options?: any,
122123
): Promise<{
@@ -127,7 +128,7 @@ export class AuthService extends AbstractService implements OnModuleInit {
127128
if (options?.scopes) scopes.push(...options.scopes);
128129
const jwtid = `${identity._id}_${randomBytes(16).toString('hex')}`;
129130
const access_token = this.jwtService.sign(
130-
{ identity: pick(identity, ['_id', 'username', 'email']), scopes },
131+
{ identity: pick(identity, ['_id', 'username', 'email', 'token']), scopes },
131132
{
132133
expiresIn: this.ACCESS_TOKEN_EXPIRES_IN,
133134
jwtid,

0 commit comments

Comments
 (0)