blob: 77ef72464aecdf3726877ffb3377214ad4b5ffb0 [file] [log] [blame]
Matteo Scandolo4eb4ccb2016-01-26 11:02:16 -08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17(function () {
Matteo Scandolo39c65a52016-01-27 12:00:18 -080018 'use strict';
Matteo Scandolo4eb4ccb2016-01-26 11:02:16 -080019
Matteo Scandolo39c65a52016-01-27 12:00:18 -080020 angular.module('cordLogin', [])
Matteo Scandoloe0628502016-01-27 14:42:42 -080021 .controller('CordLoginCtrl', function ($log, $scope, $resource, $location, $window, User) {
Matteo Scandolo4eb4ccb2016-01-26 11:02:16 -080022
Matteo Scandoloe0628502016-01-27 14:42:42 -080023 $scope.page.curr = 'login';
24
25 $scope.login = function () {
26 if ($scope.email && $scope.password) {
27 //getResource($scope.email);
28
29 User.login($scope.email, $scope.password)
30 .then(function(user){
31 $location.url('/home');
Matteo Scandolob0e65a62016-01-28 11:05:15 -080032 })
33 .catch(function(e){
34 $scope.error = true;
Matteo Scandoloe0628502016-01-27 14:42:42 -080035 });
36
37 $scope.shared.login = $scope.email;
Matteo Scandolo39c65a52016-01-27 12:00:18 -080038 }
Matteo Scandoloe0628502016-01-27 14:42:42 -080039 };
Matteo Scandolo4eb4ccb2016-01-26 11:02:16 -080040
Matteo Scandoloe0628502016-01-27 14:42:42 -080041 $log.debug('Cord Login Ctrl has been created.');
42 });
Matteo Scandolo4eb4ccb2016-01-26 11:02:16 -080043}());