Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onLogin(e, args) {
- DebugMode && console.info('[INFO]', 'Login requested on ' + new Date());
- var cred;
- var data;
- try {
- cred = args.credentials;
- data = data_login;
- } catch (ex) {
- log('warn', 'Cannot get credentials to access.');
- _toastr.warning(ex.message, ' ', 'Contate o suporte e informe a mensagem exibida.');
- $state.go('login');
- }
- // Sanitize login credentials.
- cred.username = $sanitize(cred.username);
- cred.password = $sanitize(cred.password);
- data.username = cred.username;
- data.password = cred.password;
- LoginService.doLogin(cred/*data*/).then(
- /* Success */
- function (result) {
- scope.errorLogin = false;
- rootScope.hideMenu = false;
- rootScope.loading = false;
- rootScope.$emit('operatorIsLogged', null);
- rootScope.$broadcast('operatorIsLogged', null);
- rootScope.$broadcast('getOperatorLogged', null);
- rootScope.module_permissions = PermissionsService.check_modules_permissions();
- _toastr.success(t("Login efetuado com sucesso!"), 'Login');
- dao.getList("instance", null).then(function (res) {
- rootScope.instances = res.data.data;
- _storage.session.set('instances', rootScope.instances);
- }, function (err) {
- _toastr.error("Não foi possível recuperar a lista de Instâncias, saindo do sistema.", "Solicitando o Logout!");
- rootScope.instances = null;
- rootScope.$emit('doLogout');
- });
- $state.go('master.modules');//$state.go('stcpcfg');
- /* $rootScope.current_module = JSON.parse(StorageService.session.get("current_module")); */
- }, /* Error */
- function (reason) {
- scope.errorLogin = true;
- rootScope.hideMenu = true;
- rootScope.loading = false;
- }
- );
- }
- it('testing if the onLogin function', function(){
- var data, cred;
- data = {
- username: {
- cred: {
- username: 'username'
- }
- },
- password: {
- cred: {
- password: '****'
- }
- }
- };
- srv.onLogin();
- rootScope.$emit('doLogin', srv.onLogin);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement