Exemple #1
0
 async def post(self, *, code: str, password: str, verify_password: str):
     tdoc = await token.get(code, token.TYPE_LOSTPASS)
     if not tdoc:
         raise error.InvalidTokenError(token.TYPE_LOSTPASS, code)
     if password != verify_password:
         raise error.VerifyPasswordError()
     await user.set_password(tdoc['uid'], password)
     await token.delete(code, token.TYPE_LOSTPASS)
     self.json_or_redirect(self.reverse_url('domain_main'))
Exemple #2
0
 async def get(self, *, code: str):
     tdoc = await token.get(code, token.TYPE_CHANGEMAIL)
     if not tdoc or tdoc['uid'] != self.user['_id']:
         raise error.InvalidTokenError(token.TYPE_CHANGEMAIL, code)
     mail_holder_udoc = await user.get_by_mail(tdoc['mail'])
     if mail_holder_udoc:
         raise error.UserAlreadyExistError(tdoc['mail'])
     # TODO: Ensure mail is unique
     await user.set_mail(self.user['_id'], tdoc['mail'])
     await token.delete(code, token.TYPE_CHANGEMAIL)
     self.json_or_redirect(self.reverse_url('home_security'))
Exemple #3
0
 async def post(self, *, code: str, uname: str, password: str, verify_password: str):
     validator.check_uname(uname)
     doc = await token.get(code, token.TYPE_REGISTRATION)
     if not doc:
         raise error.InvalidTokenError(token.TYPE_REGISTRATION, code)
     if re.fullmatch(r'^team\d+$', uname) or await user.get_by_uname(uname):
         raise error.UserAlreadyExistError(uname)
     if password != verify_password:
         raise error.VerifyPasswordError()
     uid = await user.add(uname, password, doc['mail'], self.remote_ip)
     await domain.set_user_role(builtin.DOMAIN_ID_SYSTEM, uid, builtin.ROLE_DEFAULT)
     await token.delete(code, token.TYPE_REGISTRATION)
     await self.update_session(new_saved=False, uid=uid)
     self.json_or_redirect(self.reverse_url('domain_main'))
Exemple #4
0
 async def get(self, *, code: str):
     doc = await token.get(code, token.TYPE_REGISTRATION)
     if not doc:
         raise error.InvalidTokenError(token.TYPE_REGISTRATION, code)
     self.render('user_register_with_code.html', mail=doc['mail'])
Exemple #5
0
 async def get(self, *, code: str):
     tdoc = await token.get(code, token.TYPE_LOSTPASS)
     if not tdoc:
         raise error.InvalidTokenError(token.TYPE_LOSTPASS, code)
     udoc = await user.get_by_uid(tdoc['uid'])
     self.render('user_lostpass_with_code.html', uname=udoc['uname'])