(userId: string, sessionId: string)
| 211 | } |
| 212 | |
| 213 | export async function validateUserAndSession(userId: string, sessionId: string) { |
| 214 | const user = await UserModel.getById(userId); |
| 215 | |
| 216 | if (!user) { |
| 217 | throw new Error('Not Found'); |
| 218 | } |
| 219 | |
| 220 | const session = await UserSessionModel.getById(sessionId); |
| 221 | |
| 222 | if (!session || session.user_id !== user.id) { |
| 223 | throw new Error('Not Found'); |
| 224 | } |
| 225 | |
| 226 | session.last_seen_at = new Date(); |
| 227 | |
| 228 | await UserSessionModel.update(session); |
| 229 | |
| 230 | return { user, session }; |
| 231 | } |
| 232 | |
| 233 | export class VerificationCodeModel { |
| 234 | static async create( |
no test coverage detected