(
domainId: string, password: string, verify: string,
uname = '', code: string,
)
| 312 | @param('uname', Types.Username, true) |
| 313 | @param('code', Types.String) |
| 314 | async post( |
| 315 | domainId: string, password: string, verify: string, |
| 316 | uname = '', code: string, |
| 317 | ) { |
| 318 | const provider = this.ctx.oauth.providers[this.tdoc.identity.provider]; |
| 319 | if (!provider) throw new SystemError(`OAuth provider ${this.tdoc.identity.provider} not found`); |
| 320 | if (provider.lockUsername) uname = this.tdoc.identity.username; |
| 321 | if (!Types.Username[1](uname)) throw new ValidationError('uname'); |
| 322 | if (password !== verify) throw new VerifyPasswordError(); |
| 323 | const randomEmail = `${randomstring(12)}@invalid.local`; // some random email to remove in the future |
| 324 | const uid = await user.create(this.tdoc.mail || randomEmail, uname, password, undefined, this.request.ip); |
| 325 | await token.del(code, token.TYPE_REGISTRATION); |
| 326 | const [id, mailDomain] = this.tdoc.mail.split('@'); |
| 327 | const $set: any = this.tdoc.set || {}; |
| 328 | if (mailDomain === 'qq.com' && !Number.isNaN(+id)) { |
| 329 | $set.avatar = `qq:${id}`; |
| 330 | $set.qq = `${id}`; |
| 331 | } |
| 332 | if (this.session.viewLang) $set.viewLang = this.session.viewLang; |
| 333 | if (Object.keys($set).length) await user.setById(uid, $set); |
| 334 | if (Object.keys(this.tdoc.setInDomain || {}).length) await domain.setUserInDomain(domainId, uid, this.tdoc.setInDomain); |
| 335 | await this.ctx.oauth.set(this.tdoc.identity.platform, this.tdoc.identity.id, uid); |
| 336 | await successfulAuth.call(this, await user.getById(domainId, uid)); |
| 337 | this.response.redirect = this.tdoc.redirect || this.url('home_settings', { category: 'preference' }); |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | class UserLostPassHandler extends Handler { |
nothing calls this directly
no test coverage detected