-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finally getting account login/logout to work
- Loading branch information
Showing
10 changed files
with
72 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from libraries.gaesessions import SessionMiddleware | ||
|
||
def webapp_add_wsgi_middleware(app): | ||
app = SessionMiddleware(app, cookie_key="asfakjsdljnljksdbcjhabschjbasjkdbcjkhasbcjkabs") | ||
return app |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
from google.appengine.ext import db | ||
from models import base | ||
|
||
from hashlib import sha256 | ||
import random | ||
import string | ||
class Account(base.CommonModel): | ||
Sid = db.StringProperty() | ||
FriendlyName = db.StringProperty() | ||
Status = db.StringProperty() | ||
AuthToken = db.StringProperty() | ||
Salt = db.StringProperty() | ||
Email = db.EmailProperty() | ||
Password = db.StringProperty() | ||
|
||
@classmethod | ||
def new(cls, key_name, email, password): | ||
Salt = ''.join(random.choice(string.digits) for x in range(32)) | ||
Sid = 'AC'+sha256(email).hexdigest() | ||
Password = sha256(Sid+password+Salt).hexdigest() | ||
AuthToken = sha256(Sid+Password).hexdigest() | ||
return cls(key_name=email,Email = email, FriendlyName = email, | ||
Sid=Sid,Status='Active',Salt=Salt, | ||
Password=Password,AuthToken=AuthToken) | ||
|
||
def check_password(self,password): | ||
return self.Password == sha256(self.Sid+password+self.Salt).hexdigest() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,16 @@ | ||
{% extends "../templates/base.html" %} | ||
{% block 'content' %} | ||
<h1 id="account_information">Account Information</h1> | ||
<h2>Account Information</h2> | ||
<p> | ||
Account Sid: {{data.account.Sid}}<br /> | ||
Account Token: {{data.account.AuthToken}}<br /> | ||
Email: {{data.account.Email}}<br /> | ||
Friendly Name: {{data.account.FriendlyName}}<br /> | ||
</p> | ||
<h2>Links</h2> | ||
<p> | ||
<a href="/phone-numbers">Phone Numbers</a><br> | ||
<a href="/logout">Logout</a> | ||
</p> | ||
{% endblock %} |