Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oauthlive #108

Merged
merged 6 commits into from
Oct 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 21 additions & 26 deletions browser/js/groceries/groceries_cost.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
<md-dialog aria-label="Cost">
<form ng-cloak id="cost">
<md-toolbar>
<div class="md-toolbar-tools">
<h2>Groceries Cost</h2>
<span flex></span>
<md-button class="md-icon-button" ng-click="cancel()">
<i class="material-icons" aria-label="Close dialog">close</i>
</md-button>
</div>
</md-toolbar>
<md-dialog-content>
<!-- COST -->
<md-input-container>
<label>Groceries Total</label>
<input placeholder="$" ng-model="price">
</md-input-container>
</md-dialog-content>
<md-dialog-actions layout="row" layout-align="end">
<md-button ng-click="submitPrice(+price)" type="submit">
Save
<md-content flex>
<navbar class="nav" header="Grocery List"></navbar>
<div id="groceries" layout="row">
<p ng-if="!showList"><a ui-sref="meals">Add some meals</a> to your grocery list to see your personalized shopping list here!</p>
<section class="grocery-list" ng-if="showList">
<md-button class="md-icon-button" ng-click="makePDF(sections)">
<md-tooltip md-direction="right">Download this list as a PDF</md-tooltip>
<ng-md-icon icon="file_download"></ng-md-icon>
</md-button>
<md-button ng-click="cancel()">
Cancel
<md-button class="md-icon-button" ng-click="showCostForm()">
<md-tooltip md-direction="right">Input grocery Cost</md-tooltip>
<ng-md-icon icon="attach_money"></ng-md-icon>
</md-button>
</md-dialog-actions>
</form>
</md-dialog>
<div ng-repeat="section in headers | orderBy : section">
<h3> {{ section }} </h3>
<md-list-item ng-repeat="item in sections[section] | orderBy: 'name'">
<p><strong>{{item.name}}</strong> || {{round(item.amount)}} {{item.unitLong}} </p>
<md-checkbox class="md-secondary" ng-model="item.wanted"></md-checkbox>
</md-list-item>
</div>
</section>
</div>
</md-content>
9 changes: 9 additions & 0 deletions browser/js/signup/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@
</div>
<div>
<md-button type="submit">Submit</md-button>
<div class="oauth">
<p>Or, with: </p>
<a href="/auth/google">
<ng-md-icon icon="google-plus-box" size="40"></ng-md-icon>
</a>
<a href="/auth/facebook">
<ng-md-icon icon="facebook-box" size="40"></ng-md-icon>
</a>
</div>
</div>
</form>
</div>
Expand Down
4 changes: 4 additions & 0 deletions browser/scss/signup/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@

#signup-form {
@include form-body;
a {
border-bottom: none;
padding: 5px;
}
}
12 changes: 11 additions & 1 deletion server/app/configure/authentication/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ module.exports = function (app, db) {
};

var verifyCallback = function (accessToken, refreshToken, profile, done) {
//get user's first name via fb oauth
let name = profile.displayName
let info = {
firstName: name.split(' ')[0],
lastName: name.split(' ').slice(1).join(' '),
};

console.log('PROFILE \n\n', profile)

User.findOne({
where: {
Expand All @@ -26,7 +34,9 @@ module.exports = function (app, db) {
return user;
} else {
return User.create({
facebook_id: profile.id
facebook_id: profile.id,
firstName: info.firstName,
lastName: info.lastName
});
}
})
Expand Down
12 changes: 11 additions & 1 deletion server/app/configure/authentication/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ module.exports = function (app, db) {
};

var verifyCallback = function (accessToken, refreshToken, profile, done) {
//get user's first name via google oauth
let name = profile.displayName
let info = {
firstName: name.split(' ')[0],
lastName: name.split(' ').slice(1).join(' '),
email: profile.emails[0].value
};

User.findOne({
where: {
Expand All @@ -27,7 +34,10 @@ module.exports = function (app, db) {
return user;
} else {
return User.create({
google_id: profile.id
google_id: profile.id,
firstName: info.firstName,
lastName: info.lastName,
email: info.email
});
}
})
Expand Down