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
    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
 def change_account_info(self, change_info, user, connection):
     account_dao = AccountDao()
     if change_info['id'] != user['account_id'] and user[
             'account_type_id'] == 2:
         raise Exception('NO_AUTH')
     if change_info['password']:
         bcrypt_password = bcrypt.hashpw(
             change_info['password'].encode('utf-8'), bcrypt.gensalt())
         change_info['password'] = bcrypt_password
     change = account_dao.update_account_info(change_info, connection)
     if not change:
         raise Exception('NO_CHANGE')
     get_account_info = account_dao.get_account_info(
         change_info, connection)
     get_account_info['editor_id'] = user['account_id']
     account_dao.create_account_log(get_account_info, connection)
     return jsonify({'MESSAGE': 'SUCCESS'}), 200