<script type="text/javascript"> app.controller('adminAuthController', function ($rootScope, $scope, $http, $window) { $scope.login = function () { $rootScope.loading = true; $http.post('<?php echo zbase_api_url(['module' => 'account', 'object' => 'user', 'method' => 'login']); ?> ', {paramOne: $scope.email, paramTwo: $scope.password}) .success(function (response) { $rootScope.loading = false; if (response.api.result.success !== undefined && response.api.result.success === true) { $window.location.href = '/admin'; } }); }; $scope.lostPassword = function () { $rootScope.loading = true; $http.post('<?php echo zbase_api_url(['module' => 'account', 'object' => 'user', 'method' => 'password']); ?> ', {email: $scope.email}) .success(function (response) { $rootScope.loading = false; }); }; } ) </script>
message: message, type: 'info', keepAfterLocationChange: keepAfterLocationChange }; } } app.factory('userService', userService); userService.$inject = ['$http','$rootScope']; function userService($http, $rootScope) { var service = {}; service.getCurrentUser = getCurrentUser; service.updateCurrentUser = updateCurrentUser; return service; function getCurrentUser() { return $http.get('<?php echo zbase_api_url(['module' => 'account', 'object' => 'user', 'method' => 'current']); ?> '); } function updateCurrentUser() { service.getCurrentUser() .then(function (response) { $rootScope.currentUser = response.data.api.result.user; }); } } var httpInterceptor = function ($provide, $httpProvider) { $provide.factory('httpInterceptor', function ($q, flashMessengerService, $rootScope) { return {
}], 'formConfiguration' => ['submit' => ['button' => ['enable' => false]]]], 'username' => ['type' => 'tab', 'label' => 'Username', 'id' => 'username', 'group' => 'accountTab', 'enable' => function () { return zbase_config_get('modules.account.widgets.account.tab.username', true); }, 'formConfiguration' => ['form' => ['startTag' => ['action' => zbase_url_from_current(), 'html' => ['attributes' => ['class' => ['zbase-ajax-form']]]]]], 'elements' => ['username' => ['type' => 'text', 'id' => 'username', 'enable' => function () { return zbase_config_get('auth.username.enable', false); }, 'label' => 'Username', 'entity' => ['property' => 'username'], 'angular' => ['ngModel' => 'currentUser.username'], 'validations' => ['required' => ['enable' => true, 'message' => 'Username is required.'], 'unique' => ['enable' => true, 'text' => function () { return 'unique:' . zbase_entity('user')->getTable() . ',username,' . zbase_auth_user()->id() . ',user_id'; }, 'message' => 'Username already exists.'], 'regex' => ['enable' => true, 'text' => function () { return 'regex:/^[a-z][a-z0-9]{5,31}$/'; }, 'message' => 'Invalid username.'], 'min' => ['enable' => true, 'text' => function () { return 'min:5'; }, 'message' => 'Username should be of 5 up to 32 characters.'], 'max' => ['enable' => true, 'text' => function () { return 'max:32'; }, 'message' => 'Username should be of 5 up to 32 characters.'], 'not_in' => ['enable' => true, 'text' => function () { $notAllowedUsernames = (require zbase_path_library('notallowedusernames.php')); $notAllowedUsernames[] = zbase_auth_user()->username(); return 'not_in:' . implode(',', $notAllowedUsernames); }, 'message' => 'Please provide a different username.']]]]], 'email' => ['type' => 'tab', 'label' => 'Email Address', 'id' => 'email', 'group' => 'accountTab', 'enable' => function () { return zbase_config_get('modules.account.widgets.account.tab.email', true); }, 'formConfiguration' => ['form' => ['startTag' => ['action' => zbase_url_from_current(), 'html' => ['attributes' => ['class' => ['zbase-ajax-form']]]]]], 'elements' => ['email' => ['type' => 'email', 'id' => 'email', 'label' => 'Email Address', 'entity' => ['property' => 'email'], 'angular' => ['ngModel' => 'currentUser.email'], 'html' => ['attributes' => ['input' => ['autocomplete' => 'off']]], 'validations' => ['required' => ['enable' => true, 'message' => 'Email address is required.'], 'unique' => ['enable' => true, 'text' => function () { return 'unique:' . zbase_entity('user')->getTable() . ',email,' . zbase_auth_user()->id() . ',user_id'; }, 'message' => 'Email address already exists.'], 'not_in' => ['enable' => true, 'text' => function () { return 'not_in:' . zbase_auth_user()->email; }, 'message' => 'Please provide a different email address.']]]]], 'password' => ['type' => 'tab', 'label' => 'Update Password', 'id' => 'password', 'group' => 'accountTab', 'enable' => function () { return zbase_config_get('modules.account.widgets.account.tab.password', true); }, 'formConfiguration' => ['form' => ['startTag' => ['action' => zbase_url_from_current(), 'html' => ['attributes' => ['class' => ['zbase-ajax-form']]]]]], 'elements' => ['header' => ['ui' => ['type' => 'component.pageHeader', 'id' => 'header', 'text' => 'To update password, enter your current password.']], 'password' => ['type' => 'password', 'id' => 'password', 'label' => null, 'validations' => ['required' => ['enable' => true, 'message' => 'Enter your account password.'], 'accountPassword' => ['enable' => true, 'message' => 'Account password don\'t match.']]]]], 'images' => ['type' => 'tab', 'label' => 'Profile Image', 'id' => 'images', 'group' => 'accountTab', 'enable' => function () { return zbase_config_get('modules.account.widgets.account.tab.images', true); }, 'position' => 90, 'formConfiguration' => ['angular' => ['form' => ['startTag' => ['html' => ['attributes' => ['ng-controller' => 'adminAccountMainController', 'flow-init' => function () { return '{headers:{\'X-CSRF-TOKEN\': \'' . zbase_csrf_token() . '\'}, target: \'' . zbase_api_url(['module' => 'account', 'object' => 'user', 'method' => 'updateProfileImage']) . '\'}'; }, 'flow-files-submitted' => '$flow.upload();']]]], 'submit' => ['button' => ['enable' => false]]]], 'elements' => ['file' => ['type' => 'file', 'id' => 'file', 'label' => 'Update Image', 'action' => function () { return zbase_api_url(['module' => 'account', 'object' => 'user', 'method' => 'updateProfileImage']); }, 'entity' => ['property' => 'file'], 'html' => ['attributes' => ['input' => ['style' => 'width: 100px;']], 'content' => ['pre' => ['enable' => true, 'view' => zbase_view_file_contents('node.files.files')]]]]]]]]];