forked from Archives/Athou_commafeed
re-implement password recovery
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 193 KiB After Width: | Height: | Size: 52 KiB |
@@ -1460,9 +1460,16 @@ module.controller('MetricsCtrl', ['$scope', 'AdminMetricsService', function($sco
|
||||
$scope.metrics = AdminMetricsService.get();
|
||||
}]);
|
||||
|
||||
module.controller('LoginCtrl', ['$scope', '$location', 'SessionService', function($scope, $location, SessionService) {
|
||||
module.controller('LoginCtrl', ['$scope', '$location', 'SessionService', 'ServerService', function($scope, $location, SessionService, ServerService) {
|
||||
$scope.model = {};
|
||||
|
||||
$scope.recovery_model = {};
|
||||
$scope.recovery = false;
|
||||
$scope.recovery_enabled = false;
|
||||
|
||||
ServerService.get(function(data) {
|
||||
$scope.recovery_enabled = data.smtpEnabled;
|
||||
});
|
||||
|
||||
var login = function(model) {
|
||||
var success = function(data) {
|
||||
window.location.href = window.location.href.substring(0, window.location.href.lastIndexOf('#'));
|
||||
@@ -1485,6 +1492,22 @@ module.controller('LoginCtrl', ['$scope', '$location', 'SessionService', functio
|
||||
$scope.login = function() {
|
||||
login($scope.model);
|
||||
};
|
||||
|
||||
$scope.toggleRecovery = function() {
|
||||
$scope.recovery = !$scope.recovery;
|
||||
};
|
||||
|
||||
var recovery_success = function(data) {
|
||||
$scope.recovery_message = "Email has ben sent. Check your inbox.";
|
||||
};
|
||||
var recovery_error = function(data) {
|
||||
$scope.recovery_message = data.data;
|
||||
};
|
||||
$scope.recover = function() {
|
||||
SessionService.passwordReset({
|
||||
email : $scope.recovery_model.email
|
||||
}, recovery_success, recovery_error);
|
||||
}
|
||||
}]);
|
||||
|
||||
module.controller('RegisterCtrl', ['$scope', '$location', 'SessionService', 'ServerService',
|
||||
|
||||
@@ -36,6 +36,7 @@ module.factory('SessionService', ['$resource', function($resource) {
|
||||
var res = {};
|
||||
res.login = $resource('rest/user/login').save;
|
||||
res.register = $resource('rest/user/register').save;
|
||||
res.passwordReset = $resource('rest/user/passwordReset').save;
|
||||
return res;
|
||||
}]);
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ label {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.clear-both {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.block {
|
||||
display: block;
|
||||
}
|
||||
@@ -63,7 +67,11 @@ label {
|
||||
}
|
||||
|
||||
.welcome .header {
|
||||
margin: 20px 0 40px 0;
|
||||
margin: 20px 0 20px 0;
|
||||
}
|
||||
|
||||
.welcome h3 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.welcome .tagline {
|
||||
@@ -73,13 +81,14 @@ label {
|
||||
}
|
||||
|
||||
.welcome .preview {
|
||||
margin: 20px 0 20px 0;
|
||||
max-width: 100%;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.welcome .demo {
|
||||
font-size: 24px;
|
||||
color: #B3B3B3;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.main .spinner {
|
||||
|
||||
@@ -6,21 +6,18 @@
|
||||
</a>
|
||||
</div>
|
||||
<div class="pull-right tagline">Bloat-free feed reader</div>
|
||||
<div class="text-center">
|
||||
<a href="#" ng-click="demoLogin()">
|
||||
<img src="images/preview.jpg" class="preview" />
|
||||
<div class="text-center clear-both">
|
||||
<img src="images/preview.jpg" class="preview" />
|
||||
<a href="#" ng-click="demoLogin()" class="demo">
|
||||
Try out the demo
|
||||
<br />
|
||||
<span class="demo">
|
||||
Try out the demo
|
||||
<br />
|
||||
<small>(some features are disabled)</small>
|
||||
</span>
|
||||
<small>(some features are disabled)</small>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6" ng-controller="LoginCtrl">
|
||||
<div class="well" id="login-panel">
|
||||
<div class="well" id="login-panel" ng-if="!recovery">
|
||||
<h3>Login</h3>
|
||||
<span class="feedback">{{message}}</span>
|
||||
<form ng-submit="login()">
|
||||
@@ -34,7 +31,21 @@
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" class="btn btn-primary" value="Log in" />
|
||||
<a class="pull-right">Forgot password?</a>
|
||||
<a href="" class="pull-right" ng-click="toggleRecovery()" ng-if="recovery_enabled">Forgot password?</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="well" id="recovery-panel" ng-if="recovery">
|
||||
<h3>Password Recovery</h3>
|
||||
<span class="feedback">{{recovery_message}}</span>
|
||||
<form ng-submit="recover()">
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
<input type="email" name="email" class="form-control" ng-model="recovery_model.email" focus="true"></input>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" class="btn btn-primary" value="Recover" />
|
||||
<input type="button" class="btn" value="Cancel" ng-click="toggleRecovery()" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user