Skip to content

Commit

Permalink
Addind loading bar for both login options
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliePessoa committed Jan 7, 2019
1 parent fe0ac20 commit ce454cc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
3 changes: 3 additions & 0 deletions frontend/auth/authService.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
};

function login(loginMethodPromisse) {
service.isLoadingUser = true;
return authObj.setPersistence(firebase.auth.Auth.Persistence.LOCAL).then(function() {
return loginMethodPromisse.then(function(response) {
return response.user;
Expand All @@ -138,6 +139,8 @@
service.sendEmailVerification(user);
throw "Error! Email not verified.";
}
}).finally(() => {
service.isLoadingUser = false;
});
}

Expand Down
6 changes: 3 additions & 3 deletions frontend/auth/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
<input type="password" name="password" ng-model="loginCtrl.user.password"
class="custom-card-input" required="true" minlength="6" aria-label="Senha">
</md-input-container>
<div layout="row" layout-align-xs="center center" layout-align="end center">
<md-button type="submit" class="md-raised md-primary" md-colors="{background: 'teal-500'}" ng-if="!loginCtrl.isLoading">
<div layout="row" layout-align-xs="center center" layout-align="end center" ng-if="!loginCtrl.isLoadingUser()">
<md-button type="submit" class="md-raised md-primary" md-colors="{background: 'teal-500'}" >
Acessar
</md-button>
<load-circle ng-if="loginCtrl.isLoading"></load-circle>
</div>
<load-circle ng-if="loginCtrl.isLoadingUser()"></load-circle>
</form>

<md-button layout="row" layout-align="start center" class="login-btn"
Expand Down
8 changes: 8 additions & 0 deletions frontend/auth/loginController.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@

var redirectPath = $stateParams.redirect;

/**
* Verify if the Auth Service is loading User.
* @returns {boolean} True if it is loading user, false if not.
*/
loginCtrl.isLoadingUser = function () {
return AuthService.isLoadingUser;
};

loginCtrl.loginWithGoogle = function loginWithGoogle() {
var promise = AuthService.loginWithGoogle();
promise.then(function success() {
Expand Down
12 changes: 12 additions & 0 deletions frontend/test/specs/auth/loginControllerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,16 @@
expect(state.go).toHaveBeenCalledWith(states.HOME);
});
});

describe('isLoadingUser()', function() {
it('should return true if AuthService.isLoadingUser is true', () => {
authService.isLoadingUser = true;
expect(logginCtrl.isLoadingUser()).toBe(true);
});

it('should return false if AuthService.isLoadingUser is false', () => {
authService.isLoadingUser = false;
expect(logginCtrl.isLoadingUser()).toBe(false);
});
});
}));

0 comments on commit ce454cc

Please sign in to comment.