MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / getDataFromCookie

Method getDataFromCookie

lib/models/multi-factor-auth.ts:135–157  ·  view source on GitHub ↗
(cookieValue: string)

Source from the content-addressed store, hash-verified

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}

Callers 1

getDataFromRequestMethod · 0.95

Calls 3

generateKeyFunction · 0.90
verifyAuthJwtFunction · 0.90
getByIdMethod · 0.45

Tested by

no test coverage detected