blob: 170abcf6384cdff47bdb7269c6b8d845d4a06bbc [file] [log] [blame]
Matteo Scandolobf14f882016-06-02 10:01:34 -07001/*
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 () {
18 'use strict';
19
20 angular.module('cordLogin', [])
21 .controller('CordLoginCtrl', function ($log, $scope, $resource, $location, $window, User) {
22
23 $scope.page.curr = 'login';
24 $scope.loading = false;
25
26 $scope.login = function () {
27 if ($scope.email && $scope.password) {
28 //getResource($scope.email);
29 $scope.loading = true;
30 User.login($scope.email, $scope.password)
31 .then(function(user){
Matteo Scandolo8cb844e2016-06-02 11:39:02 -070032 $location.url('/');
Matteo Scandolobf14f882016-06-02 10:01:34 -070033 })
34 .catch(function(e){
35 $scope.error = true;
36 })
37 .finally(function(){
38 $scope.loading = false;
39 });;
40
41 $scope.shared.login = $scope.email;
42 }
43 };
44
45 $log.debug('Cord Login Ctrl has been created.');
46 });
47}());