Ejemplo n.º 1
0
Archivo: api.py Proyecto: J4LP/J4OAuth
def user_skills(username, character_id):
    """
    Returns all the skills for a specific user
    """
    user = ldaptools.get_user(username)
    if user is None:
        return jsonify(), 404
    eve = EveTools(key_id=user.keyID[0], vcode=user.vCode[0], cache=True)
    return jsonify(skills=eve.get_skills(character_id))
Ejemplo n.º 2
0
Archivo: api.py Proyecto: J4LP/J4OAuth
def user_sheet(username, character_id):
    """
    Return the character sheet for a specific user and character
    """
    user = ldaptools.get_user(username)
    if user is None:
        return jsonify(), 404
    eve = EveTools(key_id=user.keyID[0], vcode=user.vCode[0], cache=True)
    sheet = eve.safe_request('eve/CharacterInfo', {'characterID': character_id})
    return jsonify(sheet=EveTools.auto_to_dict(sheet))
Ejemplo n.º 3
0
Archivo: api.py Proyecto: J4LP/J4OAuth
def user_assets(username, character_id):
    """
    Returns all the assets for a specific user and character
    """
    user = ldaptools.get_user(username)
    if user is None:
        return jsonify(), 404
    eve = EveTools(key_id=user.keyID[0], vcode=user.vCode[0], cache=True)
    assets = eve.safe_request('char/AssetList', {'characterID': character_id}).assets
    return jsonify(assets=EveTools.auto_to_dict(assets))
Ejemplo n.º 4
0
Archivo: api.py Proyecto: J4LP/J4OAuth
def user_wallet(username, character_id):
    """
    Returns the wallet for a specific user and character
    """
    user = ldaptools.get_user(username)
    if user is None:
        return jsonify(), 404
    eve = EveTools(key_id=user.keyID[0], vcode=user.vCode[0], cache=True)
    wallet = eve.safe_request('char/WalletJournal',
                                 {'characterID': character_id}).transactions
    return jsonify(wallet=EveTools.auto_to_dict(wallet))
Ejemplo n.º 5
0
Archivo: api.py Proyecto: J4LP/J4OAuth
def user_standings(username, character_id):
    """
    Returns all the standings for a specific user and character
    """
    user = ldaptools.get_user(username)
    if user is None:
        return jsonify(), 404
    eve = EveTools(key_id=user.keyID[0], vcode=user.vCode[0], cache=True)
    standings = eve.safe_request('char/Standings',
                                 {'characterID': character_id}).characterNPCStandings
    return jsonify(standings=EveTools.auto_to_dict(standings))
Ejemplo n.º 6
0
def login():
    """
    Login view, ties with our LDAP authentication and Flask-Login
    """
    if current_user.is_authenticated():
        # Probably coming from an OAuth request
        return redirect(request.args.get('next') or url_for('home'))
    login_form = LoginForm()
    if login_form.validate_on_submit():
        try:
            ldap_check = ldaptools.check_credentials(
                login_form.username.data, login_form.password.data)
        except Exception as e:
            # Check credentials raise an exception if there's a server issue
            flash(
                'Due to a server issue, we could not authenticate you. '
                'Please wait a bit and try again', 'danger')
            return redirect(url_for('login'))
        if ldap_check:
            user = ldaptools.get_user(login_form.username.data)
            session['admin'] = False
            if 'admin' in user.get_authgroups():
                session['admin'] = True
            login_user(user)
            app.logger.info(
                'User {0} successfully logged into J4OAUTH'.format(
                    user.get_id()))
            if request.form.get('next') == 'None':
                return redirect(url_for('home'))
            else:
                return redirect(request.form.get('next'))
        else:
            # Bad nerd
            flash('Invalid credentials, please try again.', 'danger')
            if request.form.get('next') == 'None':
                return redirect(url_for('login'))
            else:
                return redirect(url_for('login') + request.form.get('next'))
    if login_form.is_submitted() is True:
        # Form was submitted but invalid
        flash('There was an error logging you in, '
              'please check your credentials', 'danger')
    return render_template('login.html',
                           form=login_form, next=request.args.get('next'))
Ejemplo n.º 7
0
Archivo: api.py Proyecto: J4LP/J4OAuth
def user_info(username):
    """
    Returns all the auth info for a specific user and all its characters
    """
    user = ldaptools.get_user(username)
    if user is None:
        return jsonify(), 404
    eve = EveTools(key_id=user.keyID[0], vcode=user.vCode[0])
    characters = eve.safe_request('account/APIKeyInfo').key.characters
    return jsonify(user={
        'user_id': user.id,
        'main_character': user.character_name,
        'corporation': user.main_corporation,
        'alliance': user.main_alliance,
        'auth_status': user.accountStatus[0],
        'auth_groups': [group for group in user.get_authgroups()],
        'characters': [
            {'character_id': character['characterID'],
             'character_name': character['characterName'],
             'corporation_id': character['corporationID'],
             'corporation_name': character['corporationName']}
            for character in characters]
    })
Ejemplo n.º 8
0
 def user(self):
     return ldaptools.get_user(self.user_id)
Ejemplo n.º 9
0
def load_user(userid):
    return ldaptools.get_user(userid)