diff --git a/komga-webui/src/components/AuthenticationActivityTable.vue b/komga-webui/src/components/AuthenticationActivityTable.vue index db1ff6670..bfaa857b9 100644 --- a/komga-webui/src/components/AuthenticationActivityTable.vue +++ b/komga-webui/src/components/AuthenticationActivityTable.vue @@ -66,6 +66,7 @@ export default Vue.extend({ {text: this.$t('authentication_activity.ip').toString(), value: 'ip'}, {text: this.$t('authentication_activity.user_agent').toString(), value: 'userAgent'}, {text: this.$t('authentication_activity.success').toString(), value: 'success'}, + {text: this.$t('authentication_activity.source').toString(), value: 'source'}, {text: this.$t('authentication_activity.error').toString(), value: 'error'}, {text: this.$t('authentication_activity.datetime').toString(), value: 'dateTime', groupable: false}, ) diff --git a/komga-webui/src/locales/en.json b/komga-webui/src/locales/en.json index 7c9373640..95cb8500f 100644 --- a/komga-webui/src/locales/en.json +++ b/komga-webui/src/locales/en.json @@ -25,7 +25,8 @@ "datetime": "Date Time", "email": "Email", "error": "Error", - "ip": "Ip", + "ip": "IP", + "source": "Source", "success": "Success", "user_agent": "User Agent" }, @@ -541,7 +542,10 @@ "ERR_1020": "Book to upgrade does not belong to provided series", "ERR_1021": "Destination file already exists", "ERR_1022": "Newly imported book could not be scanned", - "ERR_1023": "Book already present in ReadingList" + "ERR_1023": "Book already present in ReadingList", + "ERR_1024": "OAuth2 login error: no email attribute", + "ERR_1025": "OAuth2 login error: no local user exist with that email", + "ERR_1026": "OpenID Connect login error: email not verified" }, "filter": { "age_rating": "age rating", @@ -573,7 +577,7 @@ }, "login": { "create_user_account": "Create user account", - "login": "Login", + "login": "Sign in", "unclaimed_html": "This Komga server is not yet active, you need to create a user account to be able to access it.

Choose an email and password and click on Create user account." }, "media_analysis": { diff --git a/komga-webui/src/main.ts b/komga-webui/src/main.ts index ccfeaf8c7..54e3bc18a 100644 --- a/komga-webui/src/main.ts +++ b/komga-webui/src/main.ts @@ -19,6 +19,7 @@ import komgaUsers from './plugins/komga-users.plugin' import komgaTransientBooks from './plugins/komga-transientbooks.plugin' import komgaSse from './plugins/komga-sse.plugin' import komgaTasks from './plugins/komga-tasks.plugin' +import komgaOauth2 from './plugins/komga-oauth2.plugin' import vuetify from './plugins/vuetify' import logger from './plugins/logger.plugin' import './public-path' @@ -47,6 +48,7 @@ Vue.use(komgaLibraries, {store: store, http: Vue.prototype.$http}) Vue.use(komgaSse, {eventHub: Vue.prototype.$eventHub, store: store}) Vue.use(actuator, {http: Vue.prototype.$http}) Vue.use(komgaTasks, {http: Vue.prototype.$http}) +Vue.use(komgaOauth2, {http: Vue.prototype.$http}) Vue.config.productionTip = false diff --git a/komga-webui/src/plugins/komga-oauth2.plugin.ts b/komga-webui/src/plugins/komga-oauth2.plugin.ts new file mode 100644 index 000000000..97ef203d1 --- /dev/null +++ b/komga-webui/src/plugins/komga-oauth2.plugin.ts @@ -0,0 +1,17 @@ +import {AxiosInstance} from 'axios' +import _Vue from 'vue' +import KomgaOauht2Service from '@/services/komga-oauth2.service' + +export default { + install( + Vue: typeof _Vue, + {http}: { http: AxiosInstance }) { + Vue.prototype.$komgaOauth2 = new KomgaOauht2Service(http) + }, +} + +declare module 'vue/types/vue' { + interface Vue { + $komgaOauth2: KomgaOauht2Service; + } +} diff --git a/komga-webui/src/services/komga-oauth2.service.ts b/komga-webui/src/services/komga-oauth2.service.ts new file mode 100644 index 000000000..eb3085a82 --- /dev/null +++ b/komga-webui/src/services/komga-oauth2.service.ts @@ -0,0 +1,24 @@ +import {AxiosInstance} from 'axios' +import {OAuth2ClientDto} from '@/types/komga-oauth2' + +const API_OAUTH2 = '/api/v1/oauth2' + +export default class KomgaOauht2Service { + private http: AxiosInstance + + constructor(http: AxiosInstance) { + this.http = http + } + + async getProviders(): Promise { + try { + return (await this.http.get(`${API_OAUTH2}/providers`)).data + } catch (e) { + let msg = 'An error occurred while trying to retrieve oauth2 providers' + if (e.response.data.message) { + msg += `: ${e.response.data.message}` + } + throw new Error(msg) + } + } +} diff --git a/komga-webui/src/types/komga-oauth2.ts b/komga-webui/src/types/komga-oauth2.ts new file mode 100644 index 000000000..bd4eb5031 --- /dev/null +++ b/komga-webui/src/types/komga-oauth2.ts @@ -0,0 +1,4 @@ +export interface OAuth2ClientDto { + name: string, + registrationId: string, +} diff --git a/komga-webui/src/types/komga-users.ts b/komga-webui/src/types/komga-users.ts index 7fbe8f393..2853c947e 100644 --- a/komga-webui/src/types/komga-users.ts +++ b/komga-webui/src/types/komga-users.ts @@ -42,4 +42,5 @@ interface AuthenticationActivityDto { success: Boolean, error?: string, dateTime: string, + source?: string, } diff --git a/komga-webui/src/types/social.ts b/komga-webui/src/types/social.ts new file mode 100644 index 000000000..49c8617aa --- /dev/null +++ b/komga-webui/src/types/social.ts @@ -0,0 +1,10 @@ +export const socialButtons = { + google: { + color: '#4285F4', + text: 'white', + }, + facebook: { + color: '#4267B2', + text: 'white', + }, +} diff --git a/komga-webui/src/views/Login.vue b/komga-webui/src/views/Login.vue index 3a0ce5c3c..afd1ee59c 100644 --- a/komga-webui/src/views/Login.vue +++ b/komga-webui/src/views/Login.vue @@ -1,88 +1,111 @@