def unauthorized_ogb(): """ Handle unauthorized users that visit with an out of game browser -> Redirect them to SSO """ return get_sso_redirect('linelogin', 'publicData')
def take_over_fleet(): # lets make sure we got the token we need token: SSOToken = current_user.get_a_sso_token_with_scopes( esi_scopes.fleetcomp_scopes) if token is None: # if not, get it. And then return here return get_sso_redirect('get_fleet_token', ' '.join(esi_scopes.fleetcomp_scopes)) fleet_id = get_character_fleet_id(token, current_user.get_eve_id()) if fleet_id is None: flask.flash( gettext( "You are not in a fleet, or didn't not provide rights to read them." ), "danger") return redirect(url_for("fleetoptions.fleet")) fleet_ep: EveFleetEndpoint = EveFleetEndpoint(token, fleet_id) settings_resp: Union[EveFleet, ESIResponse] = fleet_ep.get_fleet_settings() if settings_resp.is_error(): flask.flash(gettext('You are not the boss of the fleet you are in.'), 'danger') return redirect(url_for("fleetoptions.fleet")) fleet = db.session.query(CrestFleet).get(fleet_id) if fleet is None: # we don't have a setup fleet # this is the fleetsetup page return render_template("fleet/setup/fleet_url.html", fleetID=fleet_id) else: # if we got a fleet # lets remove the current use from a fleet he might be assigned too # and assign him as the new fleets comp if fleet.compID != current_user.id: oldfleet = db.session.query(CrestFleet).filter( (CrestFleet.compID == current_user.id)).first() if oldfleet is not None: oldfleet.compID = None fleet.compID = current_user.id db.session.commit() with open("set_history.log", "a+") as f: f.write('{} - {} is taking a fleet on CREST\n'.format( datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S"), fleet.comp.username)) return redirect(url_for('fleetoptions.fleet'))
def auth(): return get_sso_redirect('esi_ui', 'esi-ui.open_window.v1')
def account_self_edit(): acc_id = current_user.id char_name = request.form['default_char_name'] char_name = char_name.strip() if char_name == "": char_name = None acc: Account = db.session.query(Account).filter( Account.id == acc_id).first() if acc is None: return flask.abort(400) if char_name is not None and (current_user.get_eve_name() is None or char_name != current_user.get_eve_name()): try: char_info = outgate.character.get_info_by_name(char_name) if char_info is None: flash( gettext( "Character with name %(char_name)s could not be found!", char_name=char_name), 'danger') else: char_id = char_info.id # find out if there is a character like that in the database # or create one character = get_character_by_id(char_id) # check if character is linked to this account link = db.session.query(linked_chars) \ .filter( (linked_chars.c.id == acc_id) & ( linked_chars.c.char_id == char_id)).first() if link is None: if config.require_auth_for_chars: # this is a new link, lets redirect him # to check if he owns the character # after we saved the charid session['link_charid'] = character.id return get_sso_redirect("alt_verification", 'publicData') else: acc.characters.append(character) send_alt_link_added(account_self_edit, current_user.id, acc.id, character.id) db.session.flush() if acc.current_char != char_id: # we have a link and it is not the current char if config.require_auth_for_chars: # we need authentication for char change # so lets see if the token works auth_token: SSOToken = acc.get_a_sso_token_with_scopes( [], char_id) # we need new auth if auth_token is None: logger.debug( "Could not find a valid authorization for this character" ) session['link_charid'] = character.id return get_sso_redirect("alt_verification", 'publicData') try: auth_info = who_am_i(auth_token) except APIException: flash( gettext( 'Failed to get info for this character because of sso error' )) redirect(url_for('.account_self'), code=303) # if we don't have this the token was invalid if 'CharacterOwnerHash' not in auth_info: logger.debug( "CharacterOwnerHash was not in authorization info" ) db.session.delete(auth_token) db.session.commit() # let them re authenticate session['link_charid'] = character.id return get_sso_redirect("alt_verification", 'publicData') if auth_info[ 'CharacterOwnerHash'] != character.owner_hash: # owner hash does not match db.session.delete(auth_token) db.session.commit() session['link_charid'] = character.id logger.debug( "Character owner_owner hash did not match") return get_sso_redirect("alt_verification", 'publicData') acc.current_char = char_id except ApiException as e: flash( gettext("Could not execute action, ApiException %(ex)s", ex=e), 'danger') db.session.commit() return redirect(url_for('.account_self'), code=303)
def auth(): return get_sso_redirect('mail', 'esi-mail.send_mail.v1')