-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from omarduarte/user-auth
Adds signup and login functionality
- Loading branch information
Showing
11 changed files
with
217 additions
and
6 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
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,7 @@ | ||
(function() { | ||
|
||
'user strict'; | ||
|
||
angular.module('app.user.auth', []); | ||
|
||
})(); |
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,27 @@ | ||
<ion-view view-title="Sign In"> | ||
<ion-content> | ||
|
||
<div class="list"> | ||
<label class="item item-input"> | ||
<input type="text" ng-model="vm.credentials.email" placeholder="email"> | ||
</label> | ||
|
||
<label class="item item-input"> | ||
<input type="password" ng-model="vm.credentials.password" placeholder="password"> | ||
</label> | ||
</div> | ||
|
||
<div class="padding"> | ||
<button class="button button-block button-positive" on-tap="vm.signin(vm.credentials)"> | ||
Sign In | ||
</button> | ||
</div> | ||
|
||
<div class="card"> | ||
<div class="item item-text-wrap"> | ||
<a href="#/signup" class="button icon-right ion-chevron-right button-clear button-dark">Don't have an account? Signup</a> | ||
</div> | ||
</div> | ||
|
||
</ion-content> | ||
</ion-view> |
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,24 @@ | ||
(function() { | ||
angular | ||
.module('app.user.auth') | ||
.controller('UserSignin', UserSignin); | ||
|
||
/* @ngInject */ | ||
function UserSignin(dataservice, $state) { | ||
vm = this; | ||
vm.credentials = {}; | ||
vm.signin = signin; | ||
|
||
////////////////////////////////////// | ||
|
||
function signin(credentials) { | ||
return dataservice.signin(credentials) | ||
.then(function(result) { | ||
$state.go('moment'); | ||
}) | ||
.catch(function(err) { | ||
console.error(err); | ||
}); | ||
} | ||
} | ||
})(); |
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,31 @@ | ||
<ion-view view-title="Sign Up"> | ||
<ion-content> | ||
|
||
<div class="list"> | ||
<label class="item item-input"> | ||
<input type="text" ng-model="vm.credentials.email" placeholder="email"> | ||
</label> | ||
|
||
<label class="item item-input"> | ||
<input type="password" ng-model="vm.credentials.password" placeholder="password"> | ||
</label> | ||
|
||
<label class="item item-input"> | ||
<input ng-pattern="{{ vm.credentials.password }}" type="password" ng-model="vm.repeatPassword" placeholder="repeat password"> | ||
</label> | ||
</div> | ||
|
||
<div class="padding"> | ||
<button class="button button-block button-positive" on-tap="vm.signup(vm.credentials)"> | ||
Sign Up | ||
</button> | ||
</div> | ||
|
||
<div class="card"> | ||
<div class="item item-text-wrap"> | ||
<a href="#/signin" class="button icon-right ion-chevron-right button-clear button-dark">Already a member? Signin </a> | ||
</div> | ||
</div> | ||
|
||
</ion-content> | ||
</ion-view> |
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,27 @@ | ||
(function() { | ||
angular | ||
.module('app.user.auth') | ||
.controller('UserSignup', UserSignup); | ||
|
||
/* @ngInject */ | ||
function UserSignup(dataservice, $state) { | ||
vm = this; | ||
vm.credentials = {}; | ||
vm.repeatPassword = ''; | ||
vm.signup = signup; | ||
|
||
////////////////////////////////////// | ||
|
||
function signup(credentials) { | ||
console.log('here out!', credentials); | ||
return dataservice.signup(credentials) | ||
.then(function(result) { | ||
console.log('here!') | ||
$state.go('moment'); | ||
}) | ||
.catch(function(err) { | ||
console.error(err); | ||
}); | ||
} | ||
} | ||
})(); |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
(function() { | ||
|
||
'use strict'; | ||
|
||
angular.module('app.moment', ['app.moment.items']); | ||
})(); | ||
|
||
})(); |
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,25 @@ | ||
describe('User Authorization Process', function() { | ||
var signup; | ||
var login; | ||
var scope; | ||
var controller; | ||
var dataservice; | ||
|
||
beforeEach(function() { | ||
module('app', 'templates'); | ||
|
||
inject(function(_dataservice_, _$rootScope_, _$controller_) { | ||
dataservice = _dataservice_; | ||
scope = _$rootScope_.$new(); | ||
controller = _$controller_; | ||
}); | ||
|
||
controller = controller('UserSignup', { $scope: scope }); | ||
|
||
}); | ||
|
||
it('has a credentials object', function() { | ||
expect(controller.credentials).toBeDefined(); | ||
}); | ||
|
||
}); |