blob: 1d50b202d288ea4045f99d112a7e20ff5044678d [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';
19 var urlSuffix = '/rs/login';
Matteo Scandolo4eb4ccb2016-01-26 11:02:16 -080020
Matteo Scandolo39c65a52016-01-27 12:00:18 -080021 angular.module('cordLogin', [])
22 .controller('CordLoginCtrl', [
23 '$log', '$scope', '$resource', '$location', '$window', 'User',
24 function ($log, $scope, $resource, $location, $window, User) {
25 var LoginData, resource;
26 $scope.page.curr = 'login';
Matteo Scandolo4eb4ccb2016-01-26 11:02:16 -080027
Matteo Scandolo39c65a52016-01-27 12:00:18 -080028 function getResource(email) {
29 LoginData = $resource($scope.shared.url + urlSuffix + '/' + email);
30 resource = LoginData.get({},
31 function () {
32 $location.url('/home');
33 $window.location.href = $location.absUrl();
34 });
35 }
Matteo Scandolo4eb4ccb2016-01-26 11:02:16 -080036
Matteo Scandolo39c65a52016-01-27 12:00:18 -080037 $scope.login = function () {
38 if ($scope.email && $scope.password) {
39 //getResource($scope.email);
Matteo Scandolo4eb4ccb2016-01-26 11:02:16 -080040
Matteo Scandolo39c65a52016-01-27 12:00:18 -080041 User.login($scope.email, $scope.password)
42 .then(function(user){
43 console.log(user);
44 $location.url('/home');
45 });
46
47 $scope.shared.login = $scope.email;
48 }
49 };
50
51 $log.debug('Cord Login Ctrl has been created.');
52 }]);
Matteo Scandolo4eb4ccb2016-01-26 11:02:16 -080053}());