Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('starter.controllers', [])
- .controller('AppCtrl', function($scope, $rootScope, $window, $ionicModal, $timeout, authService, $state, $http, $ionicLoading, $location) {
- //$window.location.reload();
- $scope.loginSubmitted = false;
- $scope.myflag = false;
- $scope.User = {};
- $scope.toast = function() {
- $ionicLoading.show({
- template: 'wrong credentials'
- });
- $timeout(function() {
- $ionicLoading.hide();
- }, 1000);
- }
- $scope.footerflag = true;
- $scope.hidefooter = function() {
- $timeout(function() {
- $scope.footerflag = false;
- },1)
- }
- $scope.showfooter = function() {
- $timeout(function() {
- $scope.footerflag = true;
- },1)
- }
- $scope.doLogin = function() {
- console.log("trying login");
- // // var res = $http.post('http://login.com/postLogin', $scope.user);
- // authService.postdetails($scope.User).success(function(data, status, headers, config) {
- // $scope.message = data;
- // console.log("succesfn");
- // console.log(status);
- //
- // })
- // .error(function(data, status, headers, config) {
- // alert("failure message: " + JSON.stringify({
- // data: data
- // }));
- // console.log(fail);
- // });
- $scope.loginSubmitted = true;
- $scope.loginstatus = 0;
- authService.GetByUsername().success(function(data) {
- $scope.UserData = data;
- // console.log($scope.UserData);
- for (var i = 0; i < $scope.UserData.length; i++) {
- if ($scope.UserData[i].UserName == $scope.User.UserName && $scope.UserData[i].Password == $scope.User.Password) {
- authService.currentuser = $scope.User.UserName;
- //console.log(authService.currentuser);
- $scope.loginstatus = 1;
- break;
- }
- }
- if ($scope.loginstatus == 1) {
- // var lastVal = $cookieStore.get($scope.User.UserName);
- // console.log(lastVal);
- //$location.path('/app/playlists');
- $scope.loginstatus = 0;
- $state.go('app.playlists', null, {
- reload: true
- });
- } else {
- console.log('wrong credentials');
- $scope.toast();
- }
- }).error(function(err) {
- console.log(err);
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement