예제 #1
0
파일: home.py 프로젝트: whitefirer/vj4
 async def post_change_mail(self, *, current_password: str, mail: str):
   validator.check_mail(mail)
   udoc, mail_holder_udoc = await asyncio.gather(
     user.check_password_by_uid(self.user['_id'], current_password),
     user.get_by_mail(mail))
   # TODO(twd2): raise other errors.
   if not udoc:
     raise error.CurrentPasswordError(self.user['uname'])
   if mail_holder_udoc:
     raise error.UserAlreadyExistError(mail)
   rid, _ = await token.add(token.TYPE_CHANGEMAIL,
                            options.changemail_token_expire_seconds,
                            uid=udoc['_id'], mail=mail)
   await self.send_mail(mail, 'Change Email', 'user_changemail_mail.html',
                        url=self.reverse_url('user_changemail_with_code', code=rid),
                        uname=udoc['uname'])
   self.render('user_changemail_mail_sent.html')
예제 #2
0
파일: home.py 프로젝트: vijos/vj4
 async def post_change_mail(self, *, current_password: str, mail: str):
   validator.check_mail(mail)
   udoc, mail_holder_udoc = await asyncio.gather(
     user.check_password_by_uid(self.user['_id'], current_password),
     user.get_by_mail(mail))
   # TODO(twd2): raise other errors.
   if not udoc:
     raise error.CurrentPasswordError(self.user['uname'])
   if mail_holder_udoc:
     raise error.UserAlreadyExistError(mail)
   rid, _ = await token.add(token.TYPE_CHANGEMAIL,
                            options.changemail_token_expire_seconds,
                            uid=udoc['_id'], mail=mail)
   await self.send_mail(mail, 'Change Email', 'user_changemail_mail.html',
                        url=self.reverse_url('user_changemail_with_code', code=rid),
                        uname=udoc['uname'])
   self.render('user_changemail_mail_sent.html')