コード例 #1
0
    def signup_seller(self, account_info, connection):
        account_dao = AccountDao()

        is_existing_email = account_dao.find_account(account_info, connection)
        if is_existing_email:
            raise Exception('EXISTING_EMAIL')

        is_kr_name_taken = account_dao.find_seller_name_kr_exist(
            account_info, connection)
        if is_kr_name_taken:
            raise Exception('EXISTING_KR_NAME')

        is_en_name_taken = account_dao.find_seller_name_en_exist(
            account_info, connection)
        if is_en_name_taken:
            raise Exception('EXISTING_EN_NAME')

        bcrypt_password = bcrypt.hashpw(
            account_info['password'].encode('utf-8'), bcrypt.gensalt())
        account_info['password'] = bcrypt_password

        signed_up_account = account_dao.create_account(account_info,
                                                       connection)
        account_info['account_id'] = signed_up_account
        account_info['editor_id'] = signed_up_account
        account_info['is_active'] = 1
        account_info['profile_pic_url'] = ''
        account_info['short_desc'] = ''
        account_info['long_desc'] = ''
        account_info['close_time'] = ''
        account_info['open_time'] = ''
        account_info['delivery_policy'] = ''
        account_info['return_policy'] = ''
        account_info['zip_code'] = ''
        account_info['address_1'] = ''
        account_info['address_2'] = ''
        account_info['is_open_weekend'] = ''

        account_dao.create_account_log(account_info, connection)

        signed_up_seller = account_dao.create_seller(account_info, connection)
        account_info['seller_id'] = signed_up_seller

        account_dao.create_seller_log(account_info, connection)

        return signed_up_seller
コード例 #2
0
    def signup_account(self, account_info, connection):
        account_dao = AccountDao()

        is_existing_email = account_dao.find_account(account_info, connection)
        if is_existing_email:
            raise Exception('EXISTING_EMAIL')

        bcrypt_password = bcrypt.hashpw(
            account_info['password'].encode('utf-8'), bcrypt.gensalt())
        account_info['password'] = bcrypt_password

        signed_up_id = account_dao.create_account(account_info, connection)
        account_info['account_id'] = signed_up_id
        account_info['editor_id'] = signed_up_id
        account_info['is_active'] = 1
        account_dao.create_account_log(account_info, connection)
        return signed_up_id
コード例 #3
0
    def signin(self, login_info, connection):
        account_dao = AccountDao()
        account = account_dao.find_account(login_info, connection)

        if account:
            if account['is_active'] == 0:
                raise Exception('ACCOUNT_NOT_ACTIVE')
            if bcrypt.checkpw(login_info['password'].encode('utf-8'),
                              account['password'].encode('utf-8')):
                token = jwt.encode(
                    {
                        'account_id': account['account_id'],
                        'expiration':
                        str(datetime.utcnow() + timedelta(hours=1))
                    },
                    SECRET_KEY,
                    algorithm=ALGORITHM)
                return jsonify({'AUTHORIZATION': token}), 200
            else:
                raise Exception('CHECK_LOGIN')
        else:
            raise Exception('ACCOUNT_DOES_NOT_EXIST')