angularjs - Retaining user details on page refresh -
on login request, sending id, password & in return i'm getting unique token key, uid, email & uname , saving them in local. after user logged in, if refresh page, header changes & ask again login. how can retain values after page refresh. here code:-
angular.module('feapp').controller('loginctrl', function($scope, $rootscope, $uibmodalinstance, login, appsettings, appservices, lclstorage) { $scope.userlogin = function() { var checkbox = $("#rememberme"), userpwd = $("#regu_pwd") var requestparam = { "email_id": $scope.user.email_id, "password": $scope.user.password } if (checkbox.prop('checked')) { lclstorage.set('user_det.user_name', $('#regu_id').val()) lclstorage.set('user_det.user_pwd', $('#regu_pwd').val()) }; appservices.doapirequest(appsettings.appapi_ci.logininfo.overviewdata, requestparam, null, 'userdata').then(function(data) { $scope.bookmarkdata = data.bookmarked_careers; $rootscope.userdetails = data.user_details; $scope.error_message = data.errors; $scope.loginstatus = data.message; if ($scope.loginstatus == 'success') { $scope.login = login; $scope.login.showlogin = false; $uibmodalinstance.close($scope.login); $rootscope.login_status = "true"; lclstorage.set('userdetails', $scope.userdetails) } else { $(".login_alert").removeclass('hidden'); $rootscope.login_status = "false"; } }); }
});
Comments
Post a Comment