async def post(self, *, code: str, uname: str, password: str, verify_password: str, school_id: str = ''): doc = await token.get(code, token.TYPE_REGISTRATION) sid = None if not doc: raise error.InvalidTokenError(token.TYPE_REGISTRATION, code) if password != verify_password: raise error.VerifyPasswordError() if school_id.strip(): if not school_id.isnumeric(): raise error.InvalidArgumentError('school_id') sid = school_id.strip() uid = await system.inc_user_counter() await user.add(uid, uname, password, doc['mail'], self.remote_ip) if sid: await user.set_by_uid(uid, ojcId=sid) 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'))
async def post_change_password(self, *, current_password: str, new_password: str, verify_password: str): if new_password != verify_password: raise error.VerifyPasswordError() doc = await user.change_password(self.user['_id'], current_password, new_password) if not doc: raise error.CurrentPasswordError(self.user['_id']) self.json_or_redirect(self.url)
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'))
async def post(self, *, uname: str, password: str, verify_password: str): mail = str(uuid.uuid4()) + '@vijos.test' validator.check_mail(mail) if await user.get_by_mail(mail): raise error.UserAlreadyExistError(mail) if password != verify_password: raise error.VerifyPasswordError() uid = await system.inc_user_counter() await user.add(uid, uname, password, mail, self.remote_ip) self.json_or_redirect('/private-user-list')
async def post(self, *, code: str, uname: str, password: str, verify_password: str): doc = await token.get(code, token.TYPE_REGISTRATION) if not doc: raise error.InvalidTokenError(token.TYPE_REGISTRATION, code) if password != verify_password: raise error.VerifyPasswordError() uid = await system.inc_user_counter() await user.add(uid, uname, password, doc['mail'], self.remote_ip) await token.delete(code, token.TYPE_REGISTRATION) await self.update_session(new_saved=False, uid=uid) self.json_or_redirect(self.reverse_url('main'))
async def post(self, *, _id: int, password: str, verify_password: str): if password != verify_password: raise error.VerifyPasswordError() await user.reset_password(_id, password) self.json_or_redirect('/private-user-list')