示例#1
0
 def __init__(self, email, password):
     """
     初始化管理员对象
     @email: 登陆邮箱
     @password: 登陆密码
     """
     self.email = email
     self.password = utils.hash_passwd(password)
     self.disabled = False
示例#2
0
 def __init__(self, email, password):
     """
     初始化管理员对象
     @email: 登陆邮箱
     @password: 登陆密码
     """
     self.email = email
     self.password = utils.hash_passwd(password)
     self.disabled = False
示例#3
0
 def __init__(self, login_name, raw_password):
     """
     创建新的用户登陆对象,并自动初始化密码
     @login_name: 登陆名
     @raw_password: 登陆密码原文
     """
     self.login_name = login_name
     self.password = utils.hash_passwd(raw_password)
     self.is_ban = False
     self.create_time = datetime.datetime.now()
     self.last_modify = datetime.datetime.now()
     self.is_delete = False
示例#4
0
 def __init__(self, login_name, raw_password):
     """
     创建新的用户登陆对象,并自动初始化密码
     @login_name: 登陆名
     @raw_password: 登陆密码原文
     """
     self.login_name = login_name
     self.password = utils.hash_passwd(raw_password)
     self.is_ban = False
     self.create_time = datetime.datetime.now()
     self.last_modify = datetime.datetime.now()
     self.is_delete = False
    def post(self):
        data = request.get_json()

        # 오류 체크
        if "username" not in data or "email" not in data or "password" not in data:
            return {'error_code': 1}, HTTPStatus.BAD_REQUEST

        # 1. 이메일 유효한지 체크
        try:
            # Validate.
            valid = validate_email(data['email'])

        except EmailNotValidError as e:
            # email is not valid, exception message is human-readable
            print(str(e))
            return {'error_code': 3}, HTTPStatus.BAD_REQUEST

        # 2. 비밀 번호 암호화
        if len(data["password"]) < 4 or len(data["password"]) > 10:
            return {'error_code': 2}, HTTPStatus.BAD_REQUEST

        password = hash_passwd(data['password'])
        print(password)

        # 3. 데이터 베이스에 저장
        try:
            connection = get_mysql_connection()
            cursor = connection.cursor()
            query = ''' insert into user(username, email, password)
                        values (%s, %s, %s);'''
            param = (data['username'], data['email'], password)

            cursor.execute(query, param)
            connection.commit()
            # print('------------------확인용 -----------------')
            user_id = cursor.lastrowid

            print(user_id)

        except Error as e:
            print(e)
            return {'error_code': "{}".format(e)}

        finally:
            cursor.close()
            connection.close()

        access_token = create_access_token(identity=user_id)

        return {'token': access_token}, HTTPStatus.OK
示例#6
0
 def reset_password(self, new_password):
     """
     更新用户的密码
     @new_password: 新密码原文
     """
     self.password = utils.hash_passwd(new_password)
示例#7
0
 def reset_password(self, new_password):
     """
     更新用户的密码
     @new_password: 新密码原文
     """
     self.password = utils.hash_passwd(new_password)