agola-web/src/views/Oauth2.vue
Simone Gotti 19fdb1d08f initial implementation of projectgroups
and related tree based navigation
2019-04-02 18:08:03 +02:00

44 lines
975 B
Vue

<template>
<div>
<div>{{code}}</div>
<div>{{username}}</div>
</div>
</template>
<script>
import { oauth2callbackurl, login, fetch } from "@/util/auth";
export default {
components: {},
name: "Oauth2",
props: {},
data() {
return {
run: null,
code: this.$route.query.code,
polling: null,
username: null
};
},
methods: {
async doOauth2() {
let u = oauth2callbackurl();
u.searchParams.append("code", this.$route.query.code);
u.searchParams.append("state", this.$route.query.state);
let res = await (await fetch(u)).json();
if (res.request_type === "loginuser") {
login(res.response.token, res.response.user);
this.$router.push("/");
} else if (res.request_type === "authorize") {
this.$store.dispatch("setRegisterUser", res.response);
this.$router.push("/register");
}
}
},
created: function() {
this.doOauth2();
}
};
</script>