Merge "divide resources into handlers and models"
[releng.git] / utils / test / testapi / 3rd_party / static / testapi-ui / components / logout / logoutController.js
1 /*
2  * Licensed under the Apache License, Version 2.0 (the "License");
3  * you may not use this file except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  */
14
15 (function () {
16     'use strict';
17
18     angular
19         .module('testapiApp')
20         .controller('LogoutController', LogoutController);
21
22     LogoutController.$inject = [
23         '$location', '$window', '$timeout'
24     ];
25
26     /**
27      * TestAPI Logout Controller
28      * This controller handles logging out. In order to fully logout, the
29      * openstackid_session cookie must also be removed. The way to do that
30      * is to have the user's browser make a request to the openstackid logout
31      * page. We do this by placing the logout link as the src for an html
32      * image. After some time, the user is redirected home.
33      */
34     function LogoutController($location, $window, $timeout) {
35         var ctrl = this;
36
37         ctrl.openid_logout_url = $location.search().openid_logout;
38         var img = new Image(0, 0);
39         img.src = ctrl.openid_logout_url;
40         ctrl.redirectWait = $timeout(function() {
41             $window.location.href = '/';
42         }, 500);
43     }
44 })();