diff --git a/src/Umbraco.Web.UI.Client/gruntFile.js b/src/Umbraco.Web.UI.Client/gruntFile.js
index 29faf2debf..8a486d2df6 100644
--- a/src/Umbraco.Web.UI.Client/gruntFile.js
+++ b/src/Umbraco.Web.UI.Client/gruntFile.js
@@ -112,7 +112,7 @@ module.exports = function (grunt) {
files: [{ dest: '<%= distdir %>/js', src : '*.js', expand: true, cwd: 'src/sample files/' }]
},
vs: {
- files: [{ dest: '<%= vsdir %>/assets', src : '**', expand: true, cwd: '<%= distdir %>' }]
+ files: [{ dest: '<%= vsdir %>', src : '**', expand: true, cwd: '<%= distdir %>' }]
}
},
diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/auth.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/auth.resource.js
index eeb9aaaabe..5d1941da3a 100644
--- a/src/Umbraco.Web.UI.Client/src/common/resources/auth.resource.js
+++ b/src/Umbraco.Web.UI.Client/src/common/resources/auth.resource.js
@@ -13,20 +13,26 @@ function authResource($q, $http, umbDataFormatter, umbRequestHelper) {
/** internal method to get the api url */
function getIsAuthUrl() {
return Umbraco.Sys.ServerVariables.authenticationApiBaseUrl + "GetCurrentUser";
- }
+ }
+
+ var _currentUser;
+
return {
-
+ currentUser: _currentUser,
+
/** Logs the user in if the credentials are good */
performLogin: function (username, password) {
var deferred = $q.defer();
//send the data
$http.post(getLoginUrl(username, password)).
- success(function (data, status, headers, config) {
+ success(function (data, status, headers, config) {
+ _currentUser = data;
deferred.resolve(data);
}).
error(function (data, status, headers, config) {
+ _currentUser = data;
deferred.reject('Login failed for user ' + username);
});
diff --git a/src/Umbraco.Web.UI.Client/src/common/security/retryqueue.js b/src/Umbraco.Web.UI.Client/src/common/security/retryqueue.js
index f734eecb87..7b7d54f9c4 100644
--- a/src/Umbraco.Web.UI.Client/src/common/security/retryqueue.js
+++ b/src/Umbraco.Web.UI.Client/src/common/security/retryqueue.js
@@ -1,7 +1,10 @@
angular.module('umbraco.security.retryQueue', [])
// This is a generic retry queue for security failures. Each item is expected to expose two functions: retry and cancel.
-.factory('securityRetryQueue', ['$q', '$log', function($q, $log) {
+.factory('securityRetryQueue', ['$q', '$log', function ($q, $log) {
+
+ $log.log("loaded queue");
+
var retryQueue = [];
var service = {
// The security service puts its own handler in here!
diff --git a/src/Umbraco.Web.UI.Client/src/common/security/security.service.js b/src/Umbraco.Web.UI.Client/src/common/security/security.service.js
index ce4a3ad280..61a510ca68 100644
--- a/src/Umbraco.Web.UI.Client/src/common/security/security.service.js
+++ b/src/Umbraco.Web.UI.Client/src/common/security/security.service.js
@@ -2,10 +2,19 @@
angular.module('umbraco.security.service', [
'umbraco.security.retryQueue', // Keeps track of failed requests that need to be retried once the user logs in
+ 'umbraco.resources',
'umbraco.services'
])
-
-.factory('security', ['$http', '$q', '$location', 'securityRetryQueue', 'dialogService', function($http, $q, $location, queue, $dialog) {
+.factory('security', ['$http', '$q', '$location', 'securityRetryQueue', 'authResource', 'dialogService', '$log',
+ function ($http, $q, $location, queue, authResource, dialogService, $log) {
+
+ // Register a handler for when an item is added to the retry queue
+ queue.onItemAddedCallbacks.push(function (retryItem) {
+ if (queue.hasMore()) {
+ service.showLogin();
+ }
+ });
+
// Redirect to the given url (defaults to '/')
function redirect(url) {
@@ -21,14 +30,12 @@ angular.module('umbraco.security.service', [
throw new Error('Trying to open a dialog that is already open!');
}
- alert("here a dialog would appear");
-
- //loginDialog = $dialog.dialog();
- //loginDialog.open('security/login/form.tpl.html', 'LoginFormController').then(onLoginDialogClose);
+ loginDialog = dialogService.open({template: 'views/common/dialogs/login.html', show: true, callback: onLoginDialogClose});
}
+
function closeLoginDialog(success) {
- if (loginDialog) {
- loginDialog.close(success);
+ if (loginDialog) {
+ loginDialog = null;
}
}
@@ -42,12 +49,6 @@ angular.module('umbraco.security.service', [
}
}
- // Register a handler for when an item is added to the retry queue
- queue.onItemAddedCallbacks.push(function(retryItem) {
- if ( queue.hasMore() ) {
- service.showLogin();
- }
- });
// The public API of the service
var service = {
@@ -91,11 +92,9 @@ angular.module('umbraco.security.service', [
requestCurrentUser: function() {
if ( service.isAuthenticated() ) {
return $q.when(service.currentUser);
- } else {
- return $http.get('/current-user').then(function(response) {
- service.currentUser = response.data.user;
- return service.currentUser;
- });
+ } else {
+ service.currentUser = authResource.currentUser;
+ return service.currentUser;
}
},
diff --git a/src/Umbraco.Web.UI.Client/src/index.html b/src/Umbraco.Web.UI.Client/src/index.html
index 577bdc1b51..cd60633009 100644
--- a/src/Umbraco.Web.UI.Client/src/index.html
+++ b/src/Umbraco.Web.UI.Client/src/index.html
@@ -21,7 +21,6 @@
-