blob: eeba984132e66dcc710c90f34c97a1a31053d6f5 [file] [log] [blame]
Bri Prebilic Colee0311892015-05-15 11:27:15 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Bri Prebilic Colee0311892015-05-15 11:27:15 -07003 *
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';
Bri Prebilic Cole0e371dc2015-06-05 16:47:21 -070019 var urlSuffix = '/rs/login';
Bri Prebilic Colee0311892015-05-15 11:27:15 -070020
21 angular.module('cordLogin', [])
Bri Prebilic Cole7a5431e2015-06-08 12:53:02 -070022 .controller('CordLoginCtrl',
23 ['$log', '$scope', '$resource', '$location', '$window',
24 function ($log, $scope, $resource, $location, $window) {
Bri Prebilic Cole0e371dc2015-06-05 16:47:21 -070025 var LoginData, resource;
26 $scope.page.curr = 'login';
27
Bri Prebilic Cole7a5431e2015-06-08 12:53:02 -070028 function getResource(email) {
Bri Prebilic Cole0e371dc2015-06-05 16:47:21 -070029 LoginData = $resource($scope.shared.url + urlSuffix + '/' + email);
Bri Prebilic Cole7a5431e2015-06-08 12:53:02 -070030 resource = LoginData.get({},
31 function () {
32 $location.url('/home');
33 $window.location.href = $location.absUrl();
34 });
35 }
36
37 $scope.login = function () {
Bri Prebilic Cole7a5431e2015-06-08 12:53:02 -070038 if ($scope.email && $scope.password) {
39 getResource($scope.email);
Bri Prebilic Cole105d8d72015-06-09 11:47:13 -070040 $scope.shared.login = $scope.email;
Bri Prebilic Cole7a5431e2015-06-08 12:53:02 -070041 }
Bri Prebilic Cole0e371dc2015-06-05 16:47:21 -070042 };
43
44 $log.debug('Cord Login Ctrl has been created.');
Bri Prebilic Colee0311892015-05-15 11:27:15 -070045 }]);
46}());