Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Commit

Permalink
[FEATURE] Login: Remember me and redirect after login
Browse files Browse the repository at this point in the history
  • Loading branch information
h0vhannes committed May 26, 2015
1 parent ea86759 commit 1232eb1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
38 changes: 21 additions & 17 deletions src/js/tabs/login.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,18 @@ LoginTab.prototype.extraRoutes = [
];

LoginTab.prototype.angular = function(module) {
module.controller('LoginCtrl', ['$scope', '$location', 'rpTracker', 'rpId',
function($scope, $location, rpTracker, id) {
module.controller('LoginCtrl', ['$scope', '$location', '$sce', 'rpTracker', 'rpId',
function($scope, $location, $sce, rpTracker, id) {

$scope.error = '';
$scope.redirectTo = $location.path();
$scope.backendMessages = [];
$scope.authAction = $sce.trustAsResourceUrl(Options.backend_url + '/auth/login');

if (id.loginStatus) {
$location.path('/balance');
return;
}

function loginCallback(err) {
if (err) {
Expand All @@ -36,13 +46,11 @@ LoginTab.prototype.angular = function(module) {
return;
}

$location.path('/balance').search('');

/*
if ($.isEmptyObject($routeParams)) {
$location.path('/balance');
}
*/
if ($location.search().redirect_to) {
$location.path($location.search().redirect_to).search('');
} else {
$location.path('/balance').search('');
}

rpTracker.track('Login', {
'Status': 'success'
Expand All @@ -51,14 +59,10 @@ LoginTab.prototype.angular = function(module) {
$scope.status = '';
}

$scope.error = '';
$scope.rememberMe = true;
$scope.backendMessages = [];

if (id.loginStatus) {
$location.path('/balance');
return;
}
$scope.submitForm = function(authAction) {
$scope.redirectTo = $location.path();
$scope.authAction = $sce.trustAsResourceUrl(Options.backend_url + '/auth/' + authAction);
};

// if ($routeParams.callback === 'callback' && $routeParams.token ) {
if ($location.path() === '/login/callback' && $location.search().token) {
Expand Down
16 changes: 11 additions & 5 deletions src/templates/tabs/login.jade
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ section.col-xs-12.content(ng-controller="LoginCtrl")
br
.backend.error(ng-repeat="message in backendMessages")
span.error(ng-bind="message")
.submit-btn-container
a.btn.btn-submit.btn-block.btn-success#registerBtn(href="{{globalOptions.backend_url}}/auth/register")
span(l10n) Sign up
a.btn.btn-submit.btn-block.btn-success#loginBtn(href="{{globalOptions.backend_url}}/auth/login")
span(l10n) Sign in
form(name='loginForm' action='{{authAction}}')
.submit-btn-container
button.btn.btn-submit.btn-block.btn-success#registerBtn(type="submit" ng-click="submitForm('register')")
span(l10n) Sign Up
button.btn.btn-submit.btn-block.btn-success#loginBtn(type="submit" ng-click="submitForm('login')")
span(l10n) Sign In
.input-group.col-xs-12
input(name='redirect_to', type='hidden', value='{{redirectTo}}')
label
input.rememberMe(name='remember_me', type='checkbox')
span(for='remember_me', l10n) Remember me on this device for 30 days
.row.switch-mode-wrapper
.switch-mode-link-container.bottomText(l10n)
| Ripple Trade uses  
Expand Down

0 comments on commit 1232eb1

Please sign in to comment.