(cookieValue: string)
| 133 | } |
| 134 | |
| 135 | private static async getDataFromCookie(cookieValue: string): Promise<{ user: User } | null> { |
| 136 | if (!cookieValue) { |
| 137 | return null; |
| 138 | } |
| 139 | |
| 140 | const key = await generateKey(JWT_SECRET); |
| 141 | |
| 142 | try { |
| 143 | const token = await verifyAuthJwt(key, cookieValue) as JwtData; |
| 144 | |
| 145 | const user = await UserModel.getById(token.data.user_id); |
| 146 | |
| 147 | if (!user || token.data.session_id !== MFA_SESSION_ID) { |
| 148 | throw new Error('Not Found'); |
| 149 | } |
| 150 | |
| 151 | return { user }; |
| 152 | } catch (error) { |
| 153 | console.error(error); |
| 154 | } |
| 155 | |
| 156 | return null; |
| 157 | } |
| 158 | } |
no test coverage detected