Esempio n. 1
0
def appsettings():
    '''This function pulls some information and then renders the settings or
    error template'''
    if flask.session.get('loginid'):
        user_info = appdb.getUserInfo(flask.session['email'],
                                      flask.session['loginid'])
        loggedin = True
    else:
        user_info = False
        # indbRes = False
        return flask.render_template('deny.html',
                                     denymsg="I don't know who you are so I can't help you with your user settings. :(", loggedin = False)
    if user_info:
        rows = appdb.getDIDsbyAccount(user_info[0])
        pprint.pprint(user_info)
        accountInfo = appdb.getInfobyEmail(user_info[2])
        pprint.pprint(accountInfo)
    else:
        # loggedin = False
        return flask.render_template('homepage.html', loggedin=False)
    return flask.render_template('settings.html',
                                 user_info=user_info,
                                 account_info=accountInfo,
                                 dids=rows,
                                 loggedin=True)
Esempio n. 2
0
def landingPage():
    '''This renders the landing page'''
    # user_info = google_auth.get_user_info()
    if flask.session['loginid']:
        user_info = appdb.getUserInfo(flask.session['email'],
                                      flask.session['loginid'])
    # Going to replace google_auth with a local authentication.
    if app_auth.is_logged_in():
        loggedin = True
    else:
        loggedin = False
    return flask.render_template('landing.html',
                                 user_info=user_info,
                                 loggedin=loggedin)
Esempio n. 3
0
def index():
    '''This is the root index. If not logged in it displays homepage.html'''
    if flask.session.get('loginid'):
        user_info = appdb.getUserInfo(flask.session['email'],
                                      flask.session['loginid'])

        if not user_info:
            return flask.render_template('homepage.html', loggedin=False)

        rows = appdb.getDIDsbyAccount(flask.session['account_id'])
        return flask.render_template('index.html',
                                     name=user_info[2],
                                     picture=user_info[8],
                                     dids=rows,
                                     loggedin=True)
    else:
        return flask.render_template('homepage.html', loggedin=False)
Esempio n. 4
0
def auth_updatepw():
    '''This takes three post variables to match the old password then match two
    passwords forms then update password if it all checks out.'''

    if not is_logged_in():
        return "error"
    if flask.session['loginid']:
        user_info = appdb.getUserInfo(flask.session['email'],
                                      flask.session['loginid'])

    passzero = request.form['passwdzero']
    passone = request.form['passwdone']
    orighash = hash_password(passzero.encode('ascii'))
    newhash = hash_password(passone.encode('ascii'))
    if (appdb.updatePass(user_info[0], orighash, newhash)):
        return '200'
    return "error"
Esempio n. 5
0
def manageSingleSMS(number):
    '''This renders a view for a single SMS number and its
    associated messages'''
    if not app_auth.is_logged_in():
        return flask.render_template('deny.html',
                                     denymsg=loginMsg,
                                     loggedin=False)
    if flask.session['loginid']:
        user_info = appdb.getUserInfo(flask.session['email'],
                                      flask.session['loginid'])

    result = appdb.authIdforDID(user_info[0], number)
    prettynum = appsms.prettyPhone(number)

    if appdb.validateFrom(int(number)) and result:
        return flask.render_template('single.html',
                                     srcnumber=number,
                                     prettynum=prettynum,
                                     loggedin=True)
    else:
        return flask.render_template('notvalid.html',
                                     srcnumber=number,
                                     prettynum=prettynum,
                                     loggedin=True)