Пример #1
0
 async def get(self, *, code: str):
     self.check_oauth()
     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'])
Пример #2
0
    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'))
Пример #3
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'))
Пример #4
0
Файл: home.py Проект: 9801/vj4
 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(twd2): 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'))
Пример #5
0
Файл: user.py Проект: JoshOY/vj4
 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'))
Пример #6
0
Файл: user.py Проект: JoshOY/vj4
 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'])