fix(FE login): timezone http call
This commit is contained in:
parent
76d0a573ad
commit
d5d429e7d9
1 changed files with 10 additions and 14 deletions
|
@ -21,14 +21,14 @@ const onSubmit = () => {
|
|||
username: data.username,
|
||||
password: data.password,
|
||||
// csrf: document.querySelector('meta[name="csrf-token"]').getAttribute('content')
|
||||
}).then((response) => {
|
||||
}).then(async (response) => {
|
||||
if (response.status === 200) {
|
||||
//const timezone = setTimezone(response.data.user);
|
||||
const timezone = await setTimezone(data);
|
||||
const auth = useAuthStore();
|
||||
const user = {
|
||||
user: response.data.user,
|
||||
password: data.password,
|
||||
//timezone: timezone
|
||||
timezone: timezone
|
||||
}
|
||||
auth.setUserData(user);
|
||||
|
||||
|
@ -44,19 +44,16 @@ const onSubmit = () => {
|
|||
});
|
||||
}
|
||||
|
||||
const setTimezone = async (user): string => {
|
||||
return await axios.get("http://localhost:8080/api/v2/preferences", {
|
||||
const setTimezone = (user): Promise<string> => {
|
||||
return axios.get("http://127.0.0.1:9876/api/v2/preferences", {
|
||||
auth: {
|
||||
username: user.login,
|
||||
password: data.password
|
||||
username: user.username,
|
||||
password: user.password
|
||||
}
|
||||
}).then(res => {
|
||||
res.data.forEach(item => {
|
||||
if (item.keystr === 'user_timezone' && item.subjid === user.id) {
|
||||
return item.valstr;
|
||||
}
|
||||
return import.meta.env.VITE_APP_TIMEZONE;
|
||||
})
|
||||
const appConfig = res.data;
|
||||
const timezoneSetting = appConfig.find(setting => setting.key == 'user_locale');
|
||||
return timezoneSetting?.value ? timezoneSetting.value : import.meta.env.VITE_APP_TIMEZONE;
|
||||
}).catch(error => {
|
||||
console.log("Error: "+error);
|
||||
return null;
|
||||
|
@ -100,7 +97,6 @@ const required = (v) => {
|
|||
size="large"
|
||||
type="submit"
|
||||
variant="elevated"
|
||||
@click="onSubmit"
|
||||
block
|
||||
>
|
||||
Sign In
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue