Skip to content

Commit

Permalink
Variety of fixes focusing on login flow and culling errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lovettbarron committed Dec 18, 2017
1 parent ae0813f commit 01cb466
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 36 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Expand Up @@ -14,7 +14,7 @@
# You can create any custom variable you would like, and they will be accessible
# in the templates via {{ site.myvariable }}.
title: Grant Calculator
email: your-email@example.com
email: alb@andrewlb.com
description: >- # this means to ignore newlines until "baseurl:"
Write an awesome description for your new site here. You can edit this
line in _config.yml. It will appear in your document head meta (for
Expand Down
2 changes: 1 addition & 1 deletion _includes/header.html
Expand Up @@ -2,7 +2,7 @@
<div class="container">
<div class="row">
<div class="logo col col--xs-5 col--sm-5 col--md-5 col--lg-5">
<a href="{{ site.baseurl }}/">
<a href="{{ "/list" | prepend: site.baseurl | prepend: site.url }}">
<img src="{{ "/img/logo.png" | prepend: site.baseurl | prepend: site.url }}" />
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion _layouts/home.html
Expand Up @@ -22,7 +22,7 @@ <h2>Find the True Value of your Grant Application</h2>
<input type="password" id="password">
<label>Your EIN (optional)</label>
<input type="text" id="ein">
<button class="submit">Register/Login</button>
<button class="submit">Register or Login</button>
</form>
</div>
<div class="description">
Expand Down
9 changes: 3 additions & 6 deletions js/form.js
Expand Up @@ -11,6 +11,7 @@ gc.Views = gc.Views || {};
},
initialize: function() {
var _this = this
console.log("Init form",this.el)
if($(this.el).hasClass('page')) {
this.collection.getID()
this.getFields()
Expand All @@ -19,25 +20,21 @@ gc.Views = gc.Views || {};

submitForm: function(e) {
var _this = this
console.log("Form clicked")
var l = $(this.el).find('input').length
var t = {}

$(this.el).find('input').each(function(e,i){
t[$(i).attr('id')] = $(i).val()

})

console.log(t)

this.collection.sendData(
t, function(data,status) {
console.log(data)
// Redirect
if(String(data).match('/')) {
console.log("Redirecting")
window.location.replace(data)
}
})

},

submitField: function(e) {
Expand Down
3 changes: 2 additions & 1 deletion js/grant.js
Expand Up @@ -90,7 +90,8 @@ gc.Collections = gc.Collections || {};
},
error : function(request,error)
{
alert("Get Error: "+JSON.stringify(request));
// alert("Get Error: "+JSON.stringify(request));
callback()
}
});
}
Expand Down
47 changes: 23 additions & 24 deletions js/main.js
Expand Up @@ -19,30 +19,29 @@ var getAPIPath = function getAPIPath() {
}

function checkAuth(callback) {
if(window.location.href !== window.gc.home) {
$.ajax({
url : window.gc.api + '/auth',
type : 'GET',
xhrFields: {
withCredentials: true
},
headers: {
'Access-Control-Allow-Origin': true
},
crossDomain: true,
success : function(data,status,xfr) {
console.log("Authenticated");
callback()
},
error : function(request,error)
{
if(window.location.href !== window.gc.home) window.location.replace(window.gc.home)
else console.log("Already logged out")
}
});
} else {
callback()
}
console.log("Checking auth")
$.ajax({
url : window.gc.api + '/auth',
type : 'GET',
xhrFields: {
withCredentials: true
},
headers: {
'Access-Control-Allow-Origin': true
},
crossDomain: true,
success : function(data,status,xfr) {
console.log("Authenticated",data);
if(window.location.href == window.gc.home) window.location.replace(window.gc.home+'/list')
callback()
},
error : function(request,error)
{
if(window.location.href !== window.gc.home) window.location.replace(window.gc.home)
else console.log("Already logged out")
callback()
}
});
}

var getUrlParameter = function getUrlParameter(sParam) {
Expand Down
5 changes: 3 additions & 2 deletions js/user.js
Expand Up @@ -45,7 +45,7 @@ gc.Collections = gc.Collections || {};
dataType:'json',
data: data,
success : function(data,status,xfr) {
console.log("Put Success: ",data,status,xfr)
console.log("Put Success: ", data, status, xfr)
callback(data,status)
},
error : function(request,error)
Expand Down Expand Up @@ -75,7 +75,8 @@ gc.Collections = gc.Collections || {};
},
error : function(request,error)
{
alert("Get Error: "+JSON.stringify(request));
// alert("Get Error: "+JSON.stringify(request));
callback()
}
});
}
Expand Down

0 comments on commit 01cb466

Please sign in to comment.