示例#1
0
    def get(self, request, *args, **kwargs):
        user = request.user
        data = request.GET
        key = data.get('action_no')
        # event_type = data.get('type')
        new_mail = str(data.get('new_mail')).lower()

        # if True:
        if is_valid_mail_addr(new_mail) and (not user.email or self.check_and_set_valid_action(user, key)):
            # 返回发送成功页面
            key = self.create_verify_key()
            MailVerificationCode(user=user, code=key, type=1, data=new_mail,
                                 expired_time=datetime.now()+CommonEmailData.UPDATE_MAIL_VERIFICATION_CODE_EXPIRED_TIME).save()
            m = {'action_no': key,
                 'type': 'updateEmail',
                 'link': self.create_link(key, 'updateEmail'),
                 'new_mail': new_mail}
            send_update_mail_confirmation(new_mail, m['link'])
            if user.email:
                tpl = 'customer/safety/email/bind_mail_msg.html'
            else:
                tpl = 'customer/safety/email/new_bind_mail_msg.html'

            return render(request, tpl, m)
        else:
            if not is_valid_mail_addr(new_mail):
                m = {'msg': u'邮箱地址不正确'}
            else:
                m = {'msg': u'链接失效'}

            tpl = 'customer/safety/email/invalid_link.html'

            return render(request, tpl, m)
示例#2
0
    def get(self, request, *args, **kwargs):
        user = request.user
        mail = user.email

        key = self.__create_verify_key()
        MailVerificationCode(user=user, code=key, type=3,
                             expired_time=datetime.now()+CommonEmailData.UPDATE_MAIL_VERIFICATION_CODE_EXPIRED_TIME).save()
        m = {'link': self.__create_link(key, 'updateEmail'),
             'type': 'updateEmail',
             'new_mail': mail,
             }
        send_update_mail_confirmation(mail, m['link'])

        tpl = 'customer/safety/email/update_mail_msg.html'

        return render(request, tpl, m)