Also trigger first time oidc auto login flow for initial admin creation

This commit is contained in:
Johannes Zellner
2024-04-04 11:42:44 +02:00
parent 030e468829
commit ebe1883f8e
4 changed files with 10 additions and 7 deletions
+1 -4
View File
@@ -1913,10 +1913,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
if (error) return callback(error);
if (status !== 201) return callback(new ClientError(status, result));
that.setToken(result.token);
that.setUserInfo({ username: data.username, email: data.email, admin: true, twoFactorAuthenticationEnabled: false, source: '', avatarUrl: null });
callback(null, result.activated);
callback(null, result.token);
});
};
+7 -1
View File
@@ -14,6 +14,7 @@ app.controller('SetupController', ['$scope', 'Client', function ($scope, Client)
$scope.view = '';
$scope.initialized = false;
$scope.setupToken = '';
$scope.firstTimeLoginUrl = '';
$scope.owner = {
error: null,
@@ -36,7 +37,7 @@ app.controller('SetupController', ['$scope', 'Client', function ($scope, Client)
setupToken: $scope.setupToken
};
Client.createAdmin(data, function (error) {
Client.createAdmin(data, function (error, autoLoginToken) {
if (error && error.statusCode === 400) {
$scope.owner.busy = false;
@@ -59,6 +60,11 @@ app.controller('SetupController', ['$scope', 'Client', function ($scope, Client)
return;
}
// set token to autologin on first oidc flow
localStorage.cloudronFirstTimeToken = autoLoginToken;
$scope.firstTimeLoginUrl = '/openid/auth?client_id=cid-webadmin&scope=openid email profile&response_type=code token&redirect_uri=' + window.location.origin + '/authcallback.html';
setView('finished');
});
}
+1 -1
View File
@@ -123,7 +123,7 @@ app.controller('SetupAccountController', ['$scope', '$translate', '$http', funct
$http.post(API_ORIGIN + '/api/v1/auth/setup_account', data).success(function (data, status) {
if (status !== 201) return error(data, status);
// set token to autologin on first oauth flow
// set token to autologin on first oidc flow
localStorage.cloudronFirstTimeToken = data.accessToken;
$scope.dashboardUrl = '/openid/auth?client_id=cid-webadmin&scope=openid email profile&response_type=code token&redirect_uri=' + window.location.origin + '/authcallback.html';