blob: eae16d5a51008675b1f6609abbbe52eacaefd333 [file] [log] [blame]
Matteo Scandolo5d568612016-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 () {
18 'use strict';
19 var urlSuffix = '/rs/login';
20
21 angular.module('cordLogin', [])
22 .controller('CordLoginCtrl',
23 ['$log', '$scope', '$resource', '$location', '$window',
24 function ($log, $scope, $resource, $location, $window) {
25 var LoginData, resource;
26 $scope.page.curr = 'login';
27
28 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 }
36
37 $scope.login = function () {
38 if ($scope.email && $scope.password) {
39 getResource($scope.email);
40 $scope.shared.login = $scope.email;
41 }
42 };
43
44 $log.debug('Cord Login Ctrl has been created.');
45 }]);
46}());