mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Add:Authentication setting to show a custom message on login #2552
This commit is contained in:
		
							parent
							
								
									ae387ab397
								
							
						
					
					
						commit
						0b334cf957
					
				| @ -19,7 +19,7 @@ | |||||||
|       <div class="w-full p-1"> |       <div class="w-full p-1"> | ||||||
|         <ui-textarea-with-label v-model="newEpisode.subtitle" :label="$strings.LabelSubtitle" :rows="3" /> |         <ui-textarea-with-label v-model="newEpisode.subtitle" :label="$strings.LabelSubtitle" :rows="3" /> | ||||||
|       </div> |       </div> | ||||||
|       <div class="w-full p-1 default-style"> |       <div class="w-full p-1"> | ||||||
|         <ui-rich-text-editor :label="$strings.LabelDescription" v-model="newEpisode.description" /> |         <ui-rich-text-editor :label="$strings.LabelDescription" v-model="newEpisode.description" /> | ||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| <template> | <template> | ||||||
|   <div> |   <div class="default-style"> | ||||||
|     <p v-if="label" class="px-1 text-sm font-semibold" :class="{ 'text-gray-400': disabled }"> |     <p v-if="label" class="px-1 text-sm font-semibold" :class="{ 'text-gray-400': disabled }"> | ||||||
|       {{ label }} |       {{ label }} | ||||||
|     </p> |     </p> | ||||||
| @ -29,7 +29,7 @@ export default { | |||||||
|     config() { |     config() { | ||||||
|       return { |       return { | ||||||
|         toolbar: { |         toolbar: { | ||||||
|           getDefaultHTML: () => `    <div class="trix-button-row"> |           getDefaultHTML: () => `<div class="trix-button-row"> | ||||||
|       <span class="trix-button-group trix-button-group--text-tools" data-trix-button-group="text-tools"> |       <span class="trix-button-group trix-button-group--text-tools" data-trix-button-group="text-tools"> | ||||||
|         <button type="button" class="trix-button trix-button--icon trix-button--icon-bold" data-trix-attribute="bold" data-trix-key="b" title="#{lang.bold}" tabindex="-1">#{lang.bold}</button> |         <button type="button" class="trix-button trix-button--icon trix-button--icon-bold" data-trix-attribute="bold" data-trix-key="b" title="#{lang.bold}" tabindex="-1">#{lang.bold}</button> | ||||||
|         <button type="button" class="trix-button trix-button--icon trix-button--icon-italic" data-trix-attribute="italic" data-trix-key="i" title="#{lang.italic}" tabindex="-1">#{lang.italic}</button> |         <button type="button" class="trix-button trix-button--icon trix-button--icon-italic" data-trix-attribute="italic" data-trix-key="i" title="#{lang.italic}" tabindex="-1">#{lang.italic}</button> | ||||||
|  | |||||||
| @ -1,6 +1,18 @@ | |||||||
| <template> | <template> | ||||||
|   <div id="authentication-settings"> |   <div id="authentication-settings"> | ||||||
|     <app-settings-content :header-text="$strings.HeaderAuthentication"> |     <app-settings-content :header-text="$strings.HeaderAuthentication"> | ||||||
|  |       <div class="w-full border border-white/10 rounded-xl p-4 my-4 bg-primary/25"> | ||||||
|  |         <div class="flex items-center"> | ||||||
|  |           <ui-checkbox v-model="showCustomLoginMessage" checkbox-bg="bg" /> | ||||||
|  |           <p class="text-lg pl-4">Custom Message on Login</p> | ||||||
|  |         </div> | ||||||
|  |         <transition name="slide"> | ||||||
|  |           <div v-if="showCustomLoginMessage" class="w-full pt-4"> | ||||||
|  |             <ui-rich-text-editor v-model="newAuthSettings.authLoginCustomMessage" /> | ||||||
|  |           </div> | ||||||
|  |         </transition> | ||||||
|  |       </div> | ||||||
|  | 
 | ||||||
|       <div class="w-full border border-white/10 rounded-xl p-4 my-4 bg-primary/25"> |       <div class="w-full border border-white/10 rounded-xl p-4 my-4 bg-primary/25"> | ||||||
|         <div class="flex items-center"> |         <div class="flex items-center"> | ||||||
|           <ui-checkbox v-model="enableLocalAuth" checkbox-bg="bg" /> |           <ui-checkbox v-model="enableLocalAuth" checkbox-bg="bg" /> | ||||||
| @ -103,6 +115,7 @@ export default { | |||||||
|     return { |     return { | ||||||
|       enableLocalAuth: false, |       enableLocalAuth: false, | ||||||
|       enableOpenIDAuth: false, |       enableOpenIDAuth: false, | ||||||
|  |       showCustomLoginMessage: false, | ||||||
|       savingSettings: false, |       savingSettings: false, | ||||||
|       newAuthSettings: {} |       newAuthSettings: {} | ||||||
|     } |     } | ||||||
| @ -221,6 +234,10 @@ export default { | |||||||
|         return |         return | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|  |       if (!this.showCustomLoginMessage || !this.newAuthSettings.authLoginCustomMessage?.trim()) { | ||||||
|  |         this.newAuthSettings.authLoginCustomMessage = null | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|       this.newAuthSettings.authActiveAuthMethods = [] |       this.newAuthSettings.authActiveAuthMethods = [] | ||||||
|       if (this.enableLocalAuth) this.newAuthSettings.authActiveAuthMethods.push('local') |       if (this.enableLocalAuth) this.newAuthSettings.authActiveAuthMethods.push('local') | ||||||
|       if (this.enableOpenIDAuth) this.newAuthSettings.authActiveAuthMethods.push('openid') |       if (this.enableOpenIDAuth) this.newAuthSettings.authActiveAuthMethods.push('openid') | ||||||
| @ -250,6 +267,7 @@ export default { | |||||||
|       } |       } | ||||||
|       this.enableLocalAuth = this.authMethods.includes('local') |       this.enableLocalAuth = this.authMethods.includes('local') | ||||||
|       this.enableOpenIDAuth = this.authMethods.includes('openid') |       this.enableOpenIDAuth = this.authMethods.includes('openid') | ||||||
|  |       this.showCustomLoginMessage = !!this.authSettings.authLoginCustomMessage | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   mounted() { |   mounted() { | ||||||
|  | |||||||
| @ -28,6 +28,8 @@ | |||||||
| 
 | 
 | ||||||
|         <div class="w-full h-px bg-white bg-opacity-10 my-4" /> |         <div class="w-full h-px bg-white bg-opacity-10 my-4" /> | ||||||
| 
 | 
 | ||||||
|  |         <p v-if="loginCustomMessage" class="py-2 default-style mb-2" v-html="loginCustomMessage"></p> | ||||||
|  | 
 | ||||||
|         <p v-if="error" class="text-error text-center py-2">{{ error }}</p> |         <p v-if="error" class="text-error text-center py-2">{{ error }}</p> | ||||||
| 
 | 
 | ||||||
|         <form v-show="login_local" @submit.prevent="submitForm"> |         <form v-show="login_local" @submit.prevent="submitForm"> | ||||||
| @ -113,6 +115,9 @@ export default { | |||||||
|     }, |     }, | ||||||
|     openIDButtonText() { |     openIDButtonText() { | ||||||
|       return this.authFormData?.authOpenIDButtonText || 'Login with OpenId' |       return this.authFormData?.authOpenIDButtonText || 'Login with OpenId' | ||||||
|  |     }, | ||||||
|  |     loginCustomMessage() { | ||||||
|  |       return this.authFormData?.authLoginCustomMessage || null | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   methods: { |   methods: { | ||||||
|  | |||||||
| @ -55,7 +55,7 @@ class ServerSettings { | |||||||
|     this.buildNumber = packageJson.buildNumber |     this.buildNumber = packageJson.buildNumber | ||||||
| 
 | 
 | ||||||
|     // Auth settings
 |     // Auth settings
 | ||||||
|     // Active auth methodes
 |     this.authLoginCustomMessage = null | ||||||
|     this.authActiveAuthMethods = ['local'] |     this.authActiveAuthMethods = ['local'] | ||||||
| 
 | 
 | ||||||
|     // openid settings
 |     // openid settings
 | ||||||
| @ -113,6 +113,7 @@ class ServerSettings { | |||||||
|     this.version = settings.version || null |     this.version = settings.version || null | ||||||
|     this.buildNumber = settings.buildNumber || 0 // Added v2.4.5
 |     this.buildNumber = settings.buildNumber || 0 // Added v2.4.5
 | ||||||
| 
 | 
 | ||||||
|  |     this.authLoginCustomMessage = settings.authLoginCustomMessage || null // Added v2.7.3
 | ||||||
|     this.authActiveAuthMethods = settings.authActiveAuthMethods || ['local'] |     this.authActiveAuthMethods = settings.authActiveAuthMethods || ['local'] | ||||||
| 
 | 
 | ||||||
|     this.authOpenIDIssuerURL = settings.authOpenIDIssuerURL || null |     this.authOpenIDIssuerURL = settings.authOpenIDIssuerURL || null | ||||||
| @ -201,6 +202,7 @@ class ServerSettings { | |||||||
|       logLevel: this.logLevel, |       logLevel: this.logLevel, | ||||||
|       version: this.version, |       version: this.version, | ||||||
|       buildNumber: this.buildNumber, |       buildNumber: this.buildNumber, | ||||||
|  |       authLoginCustomMessage: this.authLoginCustomMessage, | ||||||
|       authActiveAuthMethods: this.authActiveAuthMethods, |       authActiveAuthMethods: this.authActiveAuthMethods, | ||||||
|       authOpenIDIssuerURL: this.authOpenIDIssuerURL, |       authOpenIDIssuerURL: this.authOpenIDIssuerURL, | ||||||
|       authOpenIDAuthorizationURL: this.authOpenIDAuthorizationURL, |       authOpenIDAuthorizationURL: this.authOpenIDAuthorizationURL, | ||||||
| @ -213,7 +215,7 @@ class ServerSettings { | |||||||
|       authOpenIDButtonText: this.authOpenIDButtonText, |       authOpenIDButtonText: this.authOpenIDButtonText, | ||||||
|       authOpenIDAutoLaunch: this.authOpenIDAutoLaunch, |       authOpenIDAutoLaunch: this.authOpenIDAutoLaunch, | ||||||
|       authOpenIDAutoRegister: this.authOpenIDAutoRegister, |       authOpenIDAutoRegister: this.authOpenIDAutoRegister, | ||||||
|       authOpenIDMatchExistingBy: this.authOpenIDMatchExistingBy,  |       authOpenIDMatchExistingBy: this.authOpenIDMatchExistingBy, | ||||||
|       authOpenIDMobileRedirectURIs: this.authOpenIDMobileRedirectURIs // Do not return to client
 |       authOpenIDMobileRedirectURIs: this.authOpenIDMobileRedirectURIs // Do not return to client
 | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| @ -246,6 +248,7 @@ class ServerSettings { | |||||||
| 
 | 
 | ||||||
|   get authenticationSettings() { |   get authenticationSettings() { | ||||||
|     return { |     return { | ||||||
|  |       authLoginCustomMessage: this.authLoginCustomMessage, | ||||||
|       authActiveAuthMethods: this.authActiveAuthMethods, |       authActiveAuthMethods: this.authActiveAuthMethods, | ||||||
|       authOpenIDIssuerURL: this.authOpenIDIssuerURL, |       authOpenIDIssuerURL: this.authOpenIDIssuerURL, | ||||||
|       authOpenIDAuthorizationURL: this.authOpenIDAuthorizationURL, |       authOpenIDAuthorizationURL: this.authOpenIDAuthorizationURL, | ||||||
| @ -264,7 +267,9 @@ class ServerSettings { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   get authFormData() { |   get authFormData() { | ||||||
|     const clientFormData = {} |     const clientFormData = { | ||||||
|  |       authLoginCustomMessage: this.authLoginCustomMessage | ||||||
|  |     } | ||||||
|     if (this.authActiveAuthMethods.includes('openid')) { |     if (this.authActiveAuthMethods.includes('openid')) { | ||||||
|       clientFormData.authOpenIDButtonText = this.authOpenIDButtonText |       clientFormData.authOpenIDButtonText = this.authOpenIDButtonText | ||||||
|       clientFormData.authOpenIDAutoLaunch = this.authOpenIDAutoLaunch |       clientFormData.authOpenIDAutoLaunch = this.authOpenIDAutoLaunch | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user