Browse Source
Fix Vaultwarden Admin page error messages (#4869 )
Since the change to camelCase variables the error messages in the
Vaultwarden Admin were not shown correctly anymore.
This PR fixes this by changing the case of the json key's.
Also updated the save and delete of the config to provide a more
descriptive error instead of only `Io` or which ever other error might
occure.
Fixes #4834
pull/4856/head
Mathijs van Veluw
5 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
10 additions and
4 deletions
src/api/admin.rs
src/static/scripts/admin.js
@ -750,12 +750,18 @@ fn get_diagnostics_config(_token: AdminToken) -> Json<Value> {
#[ post( " /config " , data = " <data> " ) ]
#[ post( " /config " , data = " <data> " ) ]
fn post_config ( data : Json < ConfigBuilder > , _token : AdminToken ) -> EmptyResult {
fn post_config ( data : Json < ConfigBuilder > , _token : AdminToken ) -> EmptyResult {
let data : ConfigBuilder = data . into_inner ( ) ;
let data : ConfigBuilder = data . into_inner ( ) ;
CONFIG . update_config ( data )
if let Err ( e ) = CONFIG . update_config ( data ) {
err ! ( format ! ( "Unable to save config: {e:?}" ) )
}
Ok ( ( ) )
}
}
#[ post( " /config/delete " ) ]
#[ post( " /config/delete " ) ]
fn delete_config ( _token : AdminToken ) -> EmptyResult {
fn delete_config ( _token : AdminToken ) -> EmptyResult {
CONFIG . delete_user_config ( )
if let Err ( e ) = CONFIG . delete_user_config ( ) {
err ! ( format ! ( "Unable to delete config: {e:?}" ) )
}
Ok ( ( ) )
}
}
#[ post( " /config/backup_db " ) ]
#[ post( " /config/backup_db " ) ]
@ -49,8 +49,8 @@ function _post(url, successMsg, errMsg, body, reload_page = true) {
} ) . then ( respText => {
} ) . then ( respText => {
try {
try {
const respJson = JSON . parse ( respText ) ;
const respJson = JSON . parse ( respText ) ;
if ( respJson . E rrorModel && respJson . ErrorModel . M essage) {
if ( respJson . e rrorModel && respJson . errorModel . m essage) {
return respJson . ErrorModel . M essage;
return respJson . errorModel . m essage;
} else {
} else {
return Promise . reject ( { body : ` ${ respStatus } - ${ respStatusText } \n \n Unknown error ` , error : true } ) ;
return Promise . reject ( { body : ` ${ respStatus } - ${ respStatusText } \n \n Unknown error ` , error : true } ) ;
}
}