Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.controller('SigninFormController', ['$scope', '$http', '$state', function($scope, $http, $state) {
- $scope.user = {};
- $scope.authError = null;
- $scope.login = function() {
- $scope.authError = null;
- // Try to login
- $http({
- method:'POST',
- url:'https://mywebsite.com/api/login',
- params: {
- 'number':$scope.user.number,
- 'password':$scope.user.password}
- })
- .then(function(response) {
- if ( response.data.success === false ) {
- $scope.authError = 'Email or Password not right';
- }
- else{
- $state.go('app.dashboard');
- }
- }, function(x) {
- $scope.authError = 'Login or Email no right';
- });
- }; }]);
- {"success":"false","result":"wrong email or password"}
- {"success":"true","result":"выдается jwttoken"}
- var user = {
- email: $scope.email,
- password: $scope.password
- };
- $auth.login(user)
- .then(function(response) {
- // Redirect user here after a successful log in.
- })
- .catch(function(response) {
- // Handle errors here, such as displaying a notification
- // for invalid email and/or password.
- });
- $location.path('url');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement