move profile to path param

ref #15
This commit is contained in:
Philipp Dormann 2021-03-25 19:49:35 +01:00
parent 79d8545ed6
commit a39cf75c7f
3 changed files with 12 additions and 8 deletions

View File

@ -187,8 +187,11 @@ const state = reactive({
activetab: "profile",
})
const toast = useToast();
const token = location.hash.substr(1).split('&')[0].split('=')[1];
axios.get(`${config.baseurl}api/runners/me/${token}`)
const props = defineProps({
token: String
})
const accesstoken = atob(props.token);
axios.get(`${config.baseurl}api/runners/me/${accesstoken}`)
.then(({ data }) => {
state.phone = data.phone;
state.email = data.email;
@ -199,7 +202,7 @@ axios.get(`${config.baseurl}api/runners/me/${token}`)
}).catch((error) => {
toast.error("An error occured while loading your profile data");
})
axios.get(`${config.baseurl}api/runners/me/${token}/scans`)
axios.get(`${config.baseurl}api/runners/me/${accesstoken}/scans`)
.then(({ data }) => {
data.map(function(s) {
s.lapTime = Math.floor(s.lapTime / 60) + 'min ' + (Math.floor(s.lapTime % 60) + "").padStart(2, "0") + "s"

View File

@ -10,6 +10,7 @@
v-if="state.org_name !== ''"
class="mx-auto leading-relaxed text-base text-center"
>Organization: {{ state.org_name }}</p>
<p v-else class="mx-auto leading-relaxed text-base text-center">Bürgerlauf</p>
<div class="mt-4">
<label for="first_name" class="block font-medium">
{{ $t('vorname') }}
@ -234,6 +235,7 @@ const props = defineProps({
token: String
})
if (props.token) {
props.token = atob(props.token);
axios.get(`${config.baseurl}api/organizations/selfservice/${props.token}`)
.then(({ data }) => {
console.log(data);
@ -281,10 +283,9 @@ function login() {
toast("registration in progress...");
axios.post(`${config.baseurl}api/runners/register`, postdata)
.then(({ data }) => {
const token = data.token;
const userid = JSON.parse(atob(token.split(".")[1])).id;
console.log({ token });
console.log({ userid });
const token = btoa(data.token);
// const userid = JSON.parse(atob(token.split(".")[1])).id;
location.replace("../profile/" + token)
//
toast.success("You have been registered!");
})

View File

@ -37,7 +37,7 @@ if (typeof config !== 'undefined') {
{ path: '/privacy', component: Privacy },
{ path: '/register', component: Register },
{ path: '/register/:token', component: Register, props: true },
{ path: '/profile', component: Profile }
{ path: '/profile/:token', component: Profile, props: true }
];
}
}