
In Refstack's database store only fullname, email and openid. After sign in refstack backend create session and write it id in cookie. When UI is opened in browser, Angular try to get info from /v1/profile. If data about user received then user is authenticated. Change-Id: Ib2cabc0c6b4de4b2ca1f02cc9e062a6e3550daa0
30 lines
893 B
JavaScript
30 lines
893 B
JavaScript
var refstackApp = angular.module('refstackApp');
|
|
|
|
/**
|
|
* Refstack Auth Controller
|
|
* This controller handles account authentication for users.
|
|
*/
|
|
|
|
refstackApp.controller('authController',
|
|
['$scope', '$window', '$rootScope', 'refstackApiUrl',
|
|
function($scope, $window, $rootScope, refstackApiUrl){
|
|
'use strict';
|
|
var sign_in_url = refstackApiUrl + '/auth/signin';
|
|
$scope.doSignIn = function () {
|
|
$window.location.href = sign_in_url;
|
|
};
|
|
|
|
var sign_out_url = refstackApiUrl + '/auth/signout';
|
|
$scope.doSignOut = function () {
|
|
$rootScope.currentUser = null;
|
|
$window.location.href = sign_out_url;
|
|
};
|
|
|
|
$scope.isAuthenticated = function () {
|
|
if ($scope.currentUser) {
|
|
return !!$scope.currentUser.openid;
|
|
}
|
|
return false;
|
|
};
|
|
}]);
|