mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 09:14:27 +08:00
support Nextcloud OAuth 2.0 authentication
This commit is contained in:
@@ -3,6 +3,14 @@ function getServerSetting(key: string): string | number | boolean | Record<strin
|
||||
return settings[key];
|
||||
}
|
||||
|
||||
export function isInternalAuthEnabled(): boolean {
|
||||
return getServerSetting('a') !== 0;
|
||||
}
|
||||
|
||||
export function isOAuth2Enabled(): boolean {
|
||||
return getServerSetting('o') === 1;
|
||||
}
|
||||
|
||||
export function isUserRegistrationEnabled(): boolean {
|
||||
return getServerSetting('r') === 1;
|
||||
}
|
||||
@@ -31,6 +39,14 @@ export function isDataImportingEnabled(): boolean {
|
||||
return getServerSetting('i') === 1;
|
||||
}
|
||||
|
||||
export function getOAuth2Provider(): string {
|
||||
return getServerSetting('op') as string;
|
||||
}
|
||||
|
||||
export function getOIDCCustomDisplayNames(): Record<string, string>{
|
||||
return getServerSetting('ocn') as Record<string, string>;
|
||||
}
|
||||
|
||||
export function isMCPServerEnabled(): boolean {
|
||||
return getServerSetting('mcp') === 1;
|
||||
}
|
||||
|
||||
@@ -135,6 +135,9 @@ import type {
|
||||
UserProfileUpdateRequest,
|
||||
UserProfileUpdateResponse
|
||||
} from '@/models/user.ts';
|
||||
import type {
|
||||
OAuth2CallbackLoginRequest
|
||||
} from '@/models/oauth2.ts';
|
||||
import type {
|
||||
UserApplicationCloudSettingsUpdateRequest
|
||||
} from '@/models/user_app_cloud_setting.ts';
|
||||
@@ -265,6 +268,13 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
authorizeOAuth2: ({ req, token }: { req: OAuth2CallbackLoginRequest, token: string }): ApiResponsePromise<AuthResponse> => {
|
||||
return axios.post<ApiResponse<AuthResponse>>('oauth2/authorize.json', req, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
},
|
||||
register: (req: UserRegisterRequest): ApiResponsePromise<RegisterResponse> => {
|
||||
return axios.post<ApiResponse<RegisterResponse>>('register.json', req);
|
||||
},
|
||||
@@ -695,6 +705,9 @@ export default {
|
||||
cancelRequest: (cancelableUuid: string) => {
|
||||
cancelableRequests[cancelableUuid] = true;
|
||||
},
|
||||
generateOAuth2LoginUrl: (platform: 'mobile' | 'desktop', clientSessionId: string): string => {
|
||||
return `${getBasePath()}/oauth2/login?platform=${platform}&client_session_id=${clientSessionId}`;
|
||||
},
|
||||
generateQrCodeUrl: (qrCodeName: string): string => {
|
||||
return `${getBasePath()}${BASE_QRCODE_PATH}/${qrCodeName}.png`;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user