示例#1
0
    def post(self):
        err = JsOb()
        if not self.json.email:
            err.email = 'Please input email'
        elif not is_email(self.json.email):
            err.email = 'Email not valid'
        if not self.json.password:
            err.password = '******'
        if not self.json.captcha_code:
            err.captcha_code = 'Please input captcha code'
        elif not captcha_verify(self.json.captcha_key, self.json.captcha_code):
            err.captcha_code = 'captcha code incorrect'

        if not err:
            try:
                user = User.verify(self.json.email, self.json.password)
                if user:
                    affiliate = Affiliate.find_one(dict(user_id=int(user._id)))
                    if affiliate:
                        if affiliate.status == '1':
                            self._session_new(self.json.email, user._id)
                            user.last_login = DateTime().current_time
                            user.save()
                        else:
                            err.application = 'The Account is Approving....'
                    else:
                        err.email = 'Affiliate not found, Please call the manager!'
            except UserNotFoundError:
                err.email = "email not found"
            except PasswordNotMatchError:
                err.password = "******"

        self.render(err)
示例#2
0
    def post(self):
        err = JsOb()
        if not self.json.email:
            err.email = 'Please input email'
        elif not is_email(self.json.email):
            err.email = 'Email not valid'
        if not self.json.password:
            err.password = '******'
        if not self.json.captcha_code:
            err.captcha_code = 'Please input captcha code'
        elif not captcha_verify(self.json.captcha_key, self.json.captcha_code):
            err.captcha_code = 'captcha code incorrect'

        if not err:
            try:
                user = User.verify(self.json.email, self.json.password)
                if user:
                    if user._role == 'Affiliate' or user._role == 'Advertiser':
                        err.email = u'You don\'t have a login permissions!'
                    else:
                        self._session_new(self.json.email, user._id)
                        user.last_login = DateTime().current_time
                        user.save()
            except UserNotFoundError:
                err.email = "email not found"
            except PasswordNotMatchError:
                err.password = "******"

        self.render(err)