forked from fossasia/open-event-checkin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix fossasia#14 Password Prompt added * Update NavBar.vue * Update App.vue * Renamed and Relocated Modal Files * Update SearchAttendee.vue * Flex UI fixed * Update SearchAttendee.vue * FIx fossasia#9 * Codacy Fix * Fix fossasia#30 * Codacy Fix * useApiStore comment fix * Resolved comment * Remove commented out code
- Loading branch information
Showing
8 changed files
with
200 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { mande, defaults } from 'mande' | ||
import { defineStore } from 'pinia' | ||
|
||
export const useApiStore = defineStore('api', () => { | ||
let instance = mande('https://test-api.eventyay.com/v1/') | ||
|
||
function setToken() { | ||
const token = localStorage.getItem('token') | ||
instance.options.headers.Authorization = 'JWT ' + token | ||
} | ||
|
||
function clearToken() { | ||
instance.options.headers.Authorization = '' | ||
} | ||
|
||
function newSession(authenticated) { | ||
// reinit | ||
instance = mande('https://test-api.eventyay.com/v1/') | ||
if (authenticated) { | ||
setToken() | ||
} else { | ||
clearToken() | ||
} | ||
} | ||
|
||
async function get(requiresAuth, path, payload) { | ||
newSession(requiresAuth) | ||
instance.options.headers['Accept'] = 'application/vnd.api+json' | ||
try { | ||
if (payload) { | ||
return await instance.get(path) | ||
} else { | ||
return await instance.get(path, payload) | ||
} | ||
} catch (error) { | ||
return await Promise.reject(error) | ||
} | ||
} | ||
|
||
async function post(requiresAuth, path, payload, hasBody) { | ||
newSession(requiresAuth) | ||
if (hasBody) { | ||
delete defaults.headers['Content-Type'] | ||
const options = instance.options | ||
options['body'] = payload | ||
try { | ||
return await instance.post(path) | ||
} catch (error) { | ||
return await Promise.reject(error) | ||
} | ||
} else { | ||
if (payload) { | ||
try { | ||
return await instance.post(path, payload) | ||
} catch (error) { | ||
return await Promise.reject(error) | ||
} | ||
} else { | ||
try { | ||
return await instance.post(path) | ||
} catch (error) { | ||
return await Promise.reject(error) | ||
} | ||
} | ||
} | ||
} | ||
|
||
async function remove(path) { | ||
newSession(true) | ||
try { | ||
return await instance.delete(path) | ||
} catch (error) { | ||
return await Promise.reject(error) | ||
} | ||
} | ||
|
||
async function patch(path, payload) { | ||
newSession(true) | ||
try { | ||
return await instance.patch(path, payload) | ||
} catch (error) { | ||
return await Promise.reject(error) | ||
} | ||
} | ||
return { instance, setToken, clearToken, newSession, get, post, remove, patch } | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { defineStore } from 'pinia' | ||
import { useApiStore } from '@/stores/api' | ||
|
||
export const useAuthStore = defineStore('auth', () => { | ||
// clear tokens | ||
function logoutClear() { | ||
localStorage.clear() | ||
useApiStore().clearToken() | ||
} | ||
|
||
async function logout(route) { | ||
try { | ||
await useApiStore() | ||
.post(true, route) | ||
.then(() => { | ||
logoutClear() | ||
return true | ||
}) | ||
} catch (error) { | ||
return false | ||
} | ||
} | ||
|
||
async function login(payload, route) { | ||
try { | ||
const res = await useApiStore().post(true, route, payload, false) | ||
return Object(res) | ||
} catch (error) { | ||
return error | ||
} | ||
} | ||
|
||
return { logout, login } | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ref } from 'vue' | ||
import { defineStore } from 'pinia' | ||
|
||
export const useLoadingStore = defineStore('loading', () => { | ||
const show = ref(false) | ||
|
||
return { show } | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
<script setup></script> | ||
|
||
<template> | ||
<div> | ||
<h1 class="text-center text-lg">Not Found</h1> | ||
<div class="flex min-h-full min-w-full flex-col bg-white pb-12 pt-16"> | ||
<main class="mx-auto flex w-full max-w-7xl flex-grow flex-col justify-center px-6 lg:px-8"> | ||
<div class="flex flex-shrink-0 justify-center"> | ||
</div> | ||
<div class="py-16"> | ||
<div class="text-center"> | ||
<p class="text-base font-semibold text-indigo-600">404</p> | ||
<h1 class="mt-2 text-4xl font-bold tracking-tight text-gray-900 sm:text-5xl">Page not found.</h1> | ||
<p class="mt-2 text-base text-gray-500">Sorry, we couldn’t find the page you’re looking for.</p> | ||
</div> | ||
</div> | ||
</main> | ||
</div> | ||
</template> |