Commit 8a37101f authored by janis.streib's avatar janis.streib 🦉
Browse files

ADD: new login/logout handling in frontend

parent ab159534
Pipeline #55127 passed with stages
in 2 minutes and 56 seconds
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<font-awesome-icon :icon="['far', 'user']"></font-awesome-icon> <font-awesome-icon :icon="['far', 'user']"></font-awesome-icon>
<span v-if="$store.state.user"> {{$store.state.user.login_name}}</span> <span v-if="$store.state.user"> {{$store.state.user.login_name}}</span>
</template> </template>
<b-dropdown-item v-if="$store.state.user" to="/logout">Abmelden</b-dropdown-item> <b-dropdown-item v-if="$store.state.user" @click="logout()">Abmelden</b-dropdown-item>
</b-nav-item-dropdown> </b-nav-item-dropdown>
<b-nav-item v-if="!$store.state.user"> <b-nav-item v-if="!$store.state.user">
<font-awesome-icon :icon="['far', 'user']"></font-awesome-icon> <font-awesome-icon :icon="['far', 'user']"></font-awesome-icon>
...@@ -95,6 +95,8 @@ ...@@ -95,6 +95,8 @@
</style> </style>
<script> <script>
import LoginService from '@/api-services/login.service'
export default { export default {
data() { data() {
return { return {
...@@ -129,7 +131,11 @@ ...@@ -129,7 +131,11 @@
} }
} }
return res return res
},
logout() {
LoginService.logout(this.$store.state.token.pk)
this.$store.commit('logout')
this.$router.push('/login')
} }
} }
} }
......
import Axios from 'axios'; import Axios from 'axios';
const RESOURCE_NAME = '/api/login'; const LOGIN_RESOURCE = '/api/login';
const LOGOUT_RESOURCE = '/api/logout';
export default { export default {
login(username, password) { login(username, password) {
return Axios.post(RESOURCE_NAME, {'username': username, 'password': password}) return Axios.post(LOGIN_RESOURCE, {'username': username, 'password': password})
},
logout(token_pk) {
return Axios.post(LOGOUT_RESOURCE, {'token_pk': token_pk})
} }
}; };
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment