示例#1
0
    def post(self):
        email = self.get_argument('email')
        password = self.get_argument('password')

        if not password or not email:
            self.write_error(status_code=error_codes.INVALID_ARGUMENTS,
                             reason='Invalid request, password or email not passed')
            self.set_status(400)
            return

        user = self.biz_contact_api.get_user_detail_from_email(email)

        if not user:
            self.write_error(status_code=error_codes.INVALID_EMAIL,
                             reason='Invalid email, %s not found' % email)
            self.set_status(400)
            return

        if password == user.password:
            authentication_code = authenticator.generate_authentication_code(user)
            data = {'authentication_code': authentication_code}
            self.write(data)
        else:
            self.set_status(400)
            self.write_error(status_code=error_codes.INVALID_PASSWORD,
                             reason='Invalid Password for email %s' % email)
示例#2
0
    def post(self):
        email = self.get_argument('email')
        password = self.get_argument('password')

        if not password or not email:
            self.write_error(status_code=error_codes.INVALID_ARGUMENTS,
                             reason='Invalid request, password or email not passed')
            self.set_status(400)
            return

        user = self.biz_contact_api.get_user_detail_from_email(email)

        if user:
            self.write_error(status_code=error_codes.EMAIL_ALREADY_EXIST,
                             reason='Email %s already exists' % email)
            self.set_status(400)
            return

        user = self.biz_contact_api.create_business_account(email, password,  self.get_argument('email'),
                                                            self.get_argument('first_name'),
                                                            self.get_argument('last_name'))

        self.set_header("Access-Control-Allow-Origin", "*")
        self.write({'authentication_code': authenticator.generate_authentication_code(user)})