mirror of
https://github.com/actualbudget/actual.git
synced 2026-04-29 19:14:22 -05:00
🐛 Bug FIX: OpenID first login is not working properly when using config.json or ENV VARS (#4902)
* First login was not working properly * md
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import { generators, Issuer } from 'openid-client';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import { clearExpiredSessions, getAccountDb } from '../account-db.js';
|
||||
import {
|
||||
clearExpiredSessions,
|
||||
getAccountDb,
|
||||
listLoginMethods,
|
||||
} from '../account-db.js';
|
||||
import { config } from '../load-config.js';
|
||||
import {
|
||||
getUserByUsername,
|
||||
@@ -99,10 +103,13 @@ export async function loginWithOpenIdSetup(
|
||||
[''],
|
||||
);
|
||||
if (countUsersWithUserName === 0) {
|
||||
const valid = checkPassword(firstTimeLoginPassword);
|
||||
const methods = listLoginMethods();
|
||||
if (methods.some(authMethod => authMethod.method === 'password')) {
|
||||
const valid = checkPassword(firstTimeLoginPassword);
|
||||
|
||||
if (!valid) {
|
||||
return { error: 'invalid-password' };
|
||||
if (!valid) {
|
||||
return { error: 'invalid-password' };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -108,10 +108,14 @@ function parseHTTPSConfig(value) {
|
||||
}
|
||||
|
||||
export async function run() {
|
||||
if (config.openId) {
|
||||
const openIdConfig = config?.getProperties()?.openId;
|
||||
if (
|
||||
openIdConfig?.discoveryURL ||
|
||||
openIdConfig?.issuer?.authorization_endpoint
|
||||
) {
|
||||
console.log('OpenID configuration found. Preparing server to use it');
|
||||
try {
|
||||
const { error } = await bootstrap({ openId: config.openId }, true);
|
||||
const { error } = await bootstrap({ openId: openIdConfig }, true);
|
||||
if (error) {
|
||||
console.log(error);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user