Authentification with LoginCtrl
lammh opened this issue · 1 comments
lammh commented
Hello I am new in Angularjs and angular-perminssion
I use I state for my route
i have define my permission
.run(function (PermPermissionStore) {
PermPermissionStore
.definePermission('anonymous', function () {
return true;
});
})
....
.state('app.dashboard', {
url: '/dashboard',
controller: 'DashboardCtrl',
templateUrl: 'views/tmpl/dashboard.html',
containerClass: 'sidebar-sm-forced sidebar-sm',
data: {
permissions: {
except: ['anonymous'],
redirectTo: {
state: 'login',
params: {
token: 'notSecret',
isAuthorized: 'true'
}
}
}},
i have a login view
<div class="form-group">
<input type="email" class="form-control underline-input" placeholder="Email" ng-model="user.email" required>
</div>
<div class="form-group">
<input type="password" placeholder="Mot de passe" class="form-control underline-input" ng-model="user.password" required>
</div>
<div class="form-group text-left mt-20">
<button type="submit" class="btn btn-greensea b-0 br-2 mr-5" ng-click="login()" ng-disabled='form.$invalid'>Connecter</button>
<label class="checkbox checkbox-custom checkbox-custom-sm inline-block">
<input type="checkbox"><i></i> Enregistrer
</label>
<a ui-sref="forgotpass" class="pull-right mt-10">Mot de passe oubliée?</a>
</div>
</form>
in my LoginCtrl i have a function for login
my probleme how i can use permission in function login for redirection
.controller('LoginCtrl', function ($scope, $state) {
$scope.login = function() {
$state.go('app.dashboard');
};
});
masterspambot commented
See demo from e2e tests:
https://github.com/Narzerus/angular-permission/blob/master/test/e2e/permission-ui/assets/demo.js#L116
Just replace in controller logic in authorize
method to your own redirection rule.