@@ -17,12 +17,11 @@ import { LoginRequest } from './dto'
1717export class SessionService {
1818 public constructor (
1919 private readonly prismaService : PrismaService ,
20- private readonly redisService : RedisService ,
21- private readonly configService : ConfigService
20+ private readonly redisService : RedisService
2221 ) { }
2322
2423 public async login ( dto : LoginRequest , ip : string , userAgent : string ) {
25- const { email, password } = dto
24+ const { email, password, requestId , visitorId } = dto
2625
2726 const user = await this . prismaService . user . findFirst ( {
2827 where : {
@@ -64,17 +63,22 @@ export class SessionService {
6463
6564 const ticket = await this . redisService . createMfaTicket (
6665 user . id ,
67- allowedMethods
66+ allowedMethods ,
67+ {
68+ visitorId,
69+ requestId
70+ }
6871 )
6972
7073 return ticket
7174 }
7275
73- const session = await this . redisService . createSession (
74- user ,
76+ const session = await this . redisService . createSession ( user , {
7577 ip,
76- userAgent
77- )
78+ userAgent,
79+ visitorId : visitorId ?? null ,
80+ requestId : requestId ?? null
81+ } )
7882
7983 return session
8084 }
@@ -123,11 +127,10 @@ export class SessionService {
123127 return ticket
124128 }
125129
126- const session = await this . redisService . createSession (
127- admin ,
130+ const session = await this . redisService . createSession ( admin , {
128131 ip,
129132 userAgent
130- )
133+ } )
131134
132135 return session
133136 }
@@ -232,8 +235,8 @@ export class SessionService {
232235 return {
233236 id : session . id ,
234237 createdAt : userSession . createdAt ,
235- country : userSession . geo . name ,
236- city : userSession . geo . capital ,
238+ country : userSession . geo . country ,
239+ city : userSession . geo . city ,
237240 browser : userSession . browser . name ,
238241 os : userSession . os . name
239242 }
0 commit comments