pull/6/head
Hailey Clark 6 years ago
commit 2566ed403c
  1. 3
      app.py
  2. 31
      app_auth.py
  3. 7
      database.md
  4. 1
      google_auth.py
  5. 5
      templates/settings.html

@ -11,7 +11,7 @@ from authlib.client import OAuth2Session
import google.oauth2.credentials
import googleapiclient.discovery
import appdb, appsms, app_settings
import appdb, appsms, app_settings, app_auth
import google_auth
import callback_sms
@ -155,7 +155,6 @@ def submitMessage():
@app.route('/testAjax')
def testAjax():
google_auth.getGoogleContacts()
return json.dumps({"msg" : 'Success!'})
@app.route('/launch')

@ -0,0 +1,31 @@
import hashlib, binascii, os
import google_auth
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
app_debug = config.get("app","debug")
app_salt = config.get("auth","FN_FLASK_SECRET_KEY")
def is_logged_in():
if google_auth.is_logged_in():
return True
return False
def hash_password(password):
"""Hash a password for storing."""
pwdhash = hashlib.pbkdf2_hmac('sha512', password.encode('utf-8'),
app_salt, 100000)
pwdhash = binascii.hexlify(pwdhash)
return (salt + pwdhash).decode('ascii')
def verify_password(stored_password, provided_password):
"""Verify a stored password against one provided by user"""
salt = stored_password[:64]
stored_password = stored_password[64:]
pwdhash = hashlib.pbkdf2_hmac('sha512',
provided_password.encode('utf-8'),
salt.encode('ascii'),
100000)
pwdhash = binascii.hexlify(pwdhash).decode('ascii')
return pwdhash == stored_password

@ -106,4 +106,9 @@ CREATE TABLE `phonebase` (
FOREIGN KEY (`contact_id`) REFERENCES account (id)
)
COLLATE='utf8_bin'
ENGINE=InnoDB;
ENGINE=InnoDB;
########### Update V5
# Adding password and username support.
ALTER TABLE account ADD COLUMN `username` VARCHAR(255) NULL UNIQUE;
ALTER TABLE account ADD COLUMN `passwd` VARCHAR(255) NULL;

@ -25,7 +25,6 @@ AUTHORIZATION_URL = 'https://accounts.google.com/o/oauth2/v2/auth?prompt=consent
AUTHORIZATION_SCOPE = ['openid', 'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/contacts.readonly',
'https://www.googleapis.com/auth/user.phonenumbers.read']
AUTH_REDIRECT_URI = config.get("auth","FN_AUTH_REDIRECT_URI")

@ -18,6 +18,11 @@
<div class='largeField'><h3>Google Info</h3></div>
<div class='googleID'>Google ID: {{ user_info.id }}</div>
</div>
<div id='passwdForm'>
<div class='passwd'>Password: <input type='password' id='passwdone' /></div>
<div class='passwd'>Confirm: <input type='password' id='passwdtwo' /></div>
<div class='submitpw'><input type='button' value='Update Password' /></div>
</div>
Your active DIDs: (Click number to access messaging)
<ul>
{% for item in dids %}

Loading…
Cancel
Save