login user

This commit is contained in:
2023-11-04 15:12:27 +09:00
parent f60f97380f
commit 617b060869
8 changed files with 141 additions and 136 deletions

View File

@@ -223,7 +223,7 @@ const newDomain = () => {
const activeDomain = (id:number) => {
api.put(`http://127.0.0.1:8000/api/activedomain/1/`+ id).then(() =>{
api.put(`http://127.0.0.1:8000/api/activedomain/`+ id).then(() =>{
getDomain();
})
};
@@ -248,16 +248,16 @@ const closeDg = (val:string) => {
{
dodmainids.push(domains[key].id);
}
api.post(`http://127.0.0.1:8000/api/domain/1`, dodmainids).then(() =>{getDomain();});
api.post(`http://127.0.0.1:8000/api/domain`, dodmainids).then(() =>{getDomain();});
}
};
const getDomain = () => {
api.get(`http://127.0.0.1:8000/api/activedomain/1`).then(res => {
api.get(`http://127.0.0.1:8000/api/activedomain`).then(res => {
activedomainid.value = res.data.id;
authStore.changedomain(res.data.name);
});
api.get(`http://127.0.0.1:8000/api/domain/1`).then(res => {
api.get(`http://127.0.0.1:8000/api/domain`).then(res => {
rows.length = 0;
res.data.forEach((item) => {
rows.push({ id:item.id,name: item.name, url: item.url, kintoneuser: item.kintoneuser, kintonepwd: item.kintonepwd});

View File

@@ -7,7 +7,6 @@ export const useAuthStore = defineStore({
id: 'auth',
state: () => ({
token: localStorage.getItem('token'),
id:localStorage.getItem('id'),
name:localStorage.getItem('name'),
domain:localStorage.getItem('domain'),
returnUrl: ''
@@ -21,12 +20,12 @@ export const useAuthStore = defineStore({
const result = await api.post(`http://127.0.0.1:8000/api/token`,params);
console.info(result);
this.token =result.data.access_token;
this.id = result.data.user_id;
this.name = result.data.user_name;
localStorage.setItem('token', result.data.access_token);
localStorage.setItem('id', result.data.user_id);
localStorage.setItem('name', result.data.user_name);
const activedomain = await api.get(`http://127.0.0.1:8000/api/activedomain/`+this.id);
const config = {headers:{Authorization : 'Bearer ' + this.token}};
const activedomain = await api.get(`http://127.0.0.1:8000/api/activedomain`,config);
this.domain = activedomain.data.name;
localStorage.setItem('domain', activedomain.data.name);
Router.push(this.returnUrl || '/');