MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / get

Method get

packages/hydrooj/src/handler/user.ts:166–186  ·  view source on GitHub ↗
(domainId: string, uname: string, login: boolean)

Source from the content-addressed store, hash-verified

164 @param('uname', Types.Username, true)
165 @param('login', Types.Boolean)
166 async get(domainId: string, uname: string, login: boolean) {
167 let allowCredentials = [];
168 let uid = 0;
169 if (!login) {
170 const udoc = this.user._id ? this.user : ((await user.getByEmail(domainId, uname)) || await user.getByUname(domainId, uname));
171 if (!udoc._id) throw new UserNotFoundError(uname || 'user');
172 if (!udoc.authn) throw new AuthOperationError('authn', 'disabled');
173 allowCredentials = udoc._authenticators.map((authenticator) => ({
174 id: isoBase64URL.fromBuffer(new Uint8Array(authenticator.credentialID.buffer)),
175 }));
176 uid = udoc._id;
177 }
178 const options = await generateAuthenticationOptions({
179 allowCredentials,
180 rpID: this.getAuthnHost(),
181 userVerification: 'preferred',
182 });
183 await token.add(token.TYPE_WEBAUTHN, 60, { uid: login ? 'login' : uid }, options.challenge);
184 this.session.challenge = options.challenge;
185 this.response.body.authOptions = options;
186 }
187
188 async post({ domainId, result, redirect }) {
189 const challenge = this.session.challenge;

Callers

nothing calls this directly

Calls 4

getAuthnHostMethod · 0.95
getByEmailMethod · 0.80
getByUnameMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected