We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
app.controller('LoginController', ['$scope', 'USER_ROLES', '$state', 'PermPermissionStore', 'PermRoleStore', function ($scope, USER_ROLES, $state, PermPermissionStore, PermRoleStore) {
/** * @argument {Clean session user} */ PermPermissionStore.clearStore(); PermRoleStore.clearStore(); const admin_permissions = ['canCreate', 'canRead', 'canUpdate', 'canDelete']; const user_permissions = ['canRead']; PermRoleStore.defineRole('ADMIN', ['canCreate', 'canRead', 'canUpdate', 'canDelete']); PermRoleStore.defineRole('USER', ['canRead']); $scope.login = {}; const verifyUser = async function (object) { username = object.username; password = object.password; const status = {}; if ((username == 'admin') && (password == 'admin')) { status.valid = true; status.permissions = admin_permissions; status.username = 'ADMIN'; } else if ((username == 'user') && (password == 'user')) { status.valid = true; status.permissions = user_permissions; status.username = 'USER'; } else status.valid = false; return status; }; $scope.login = async function () { let user = $scope.login; user_status = await verifyUser(user); if (user_status.valid) { PermRoleStore.defineRole(user_status.username, [user_status.permissions]); $state.go('home'); } else { $scope.error = true; setTimeout(() => { $scope.error = false; }, 2000); } };
}]); this is my login controller,
app.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', function ($stateProvider, $urlRouterProvider, $locationProvider) {
$locationProvider.hashPrefix(''); $urlRouterProvider.otherwise("/login"); $stateProvider .state('login', { url: '/login', controller: 'LoginController', templateUrl: 'template/login/login.inc.html' }) .state('home', { url: '/home', controller: 'homeController', templateUrl: 'template/home/home.inc.html', data: { permissions: { only: ['ADMIN','USER'], redirectTo: 'unauthorized' } } }) .state('user', { url: '/user', controller: 'UserController', templateUrl: 'template/user/user.inc.html', data: { permissions: { only: ['USER'], redirectTo: 'unauthorized' } } }) .state('unauthorized', { url: '/unauthorized', templateUrl: 'template/error/403.inc.html' }) ;
}]);
this is my route controller,
<div class="col-md-12"> <div class="row"> <h1 class="page-header"> Admin page <button class="btn btn-info btn-sm pull-right" ng-click="logout();"> Logout </button> </h1> </div> <div class="row"> <a permission permission-only="'canCreate'" ui-sref="home.add" class="btn btn-primary btn-sm pull-right"> <span class="glyphicon glyphicon-plus"></span> </a> <table class="table table-striped table-hoveres" permission permission-only="'canRead'"> <thead> <th>No</th> <th>Nim</th> <th>Nama</th> <th>Action</th> </thead> <tbody> <tr> <td>1</td> <td>2013140178</td> <td>Ferdina kusumah</td> <td> <a href="#" class="btn btn-warning btn-sm" permission permission-only="'canEdit'"> <span class="glyphicon glyphicon-edit"></span> </a> <a href="#" class="btn btn-danger btn-sm" permission permission-only="'canDelete'"> <span class="glyphicon glyphicon-trash"></span> </a> </td> </tr> </tbody> </table> </div> </div>
this is my view.
thank youu
The text was updated successfully, but these errors were encountered:
No branches or pull requests
app.controller('LoginController', ['$scope', 'USER_ROLES', '$state', 'PermPermissionStore', 'PermRoleStore', function ($scope, USER_ROLES, $state, PermPermissionStore, PermRoleStore) {
}]);
this is my login controller,
app.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', function ($stateProvider, $urlRouterProvider, $locationProvider) {
}]);
this is my route controller,
<style> table th, table tr td{ text-align: center; } </style>this is my view.
thank youu
The text was updated successfully, but these errors were encountered: