-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic auth logic for leed scanning
- Loading branch information
Showing
9 changed files
with
213 additions
and
25 deletions.
There are no files selected for viewing
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
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,82 @@ | ||
<script setup> | ||
import { ref, onMounted } from 'vue' | ||
import { useRouter } from 'vue-router' | ||
import { useLoadingStore } from '@/stores/loading' | ||
import { useAuthStore } from '@/stores/auth' | ||
import { useUserStore } from '@/stores/user' | ||
import { useleedauth } from '@/stores/leedauth' | ||
import StandardButton from '@/components/Common/StandardButton.vue' | ||
const loadingStore = useLoadingStore() | ||
const authStore = useAuthStore() | ||
const userStore = useUserStore() | ||
const leedauth = useleedauth() | ||
const showError = ref(false) | ||
const userId = ref('') | ||
const password = ref('') | ||
const server = ref('') | ||
// router | ||
const router = useRouter() | ||
async function submitLogin() { | ||
const payload = { | ||
email: email.value, | ||
key: password.value | ||
} | ||
console.log(payload) | ||
console.log(JSON.stringify(payload)) | ||
const response = await leedauth.leedlogin(payload) | ||
console.log(response) | ||
} | ||
loadingStore.contentLoaded() | ||
</script> | ||
|
||
<template> | ||
<div class="-mt-16 flex h-screen flex-col justify-center"> | ||
<div class="my-auto sm:mx-auto sm:w-full sm:max-w-sm"> | ||
<h2 class="text-center">Sign in with your credentials</h2> | ||
<form class="mt-10 space-y-3" @submit.prevent="submitLogin"> | ||
<div> | ||
<label for="email">User ID</label> | ||
<div class="mt-2"> | ||
<input | ||
id="email" | ||
v-model="email" | ||
name="email" | ||
type="email" | ||
required="true" | ||
class="block w-full" | ||
/> | ||
</div> | ||
</div> | ||
|
||
<div> | ||
<label for="password">Password</label> | ||
<div class="mt-2"> | ||
<input | ||
id="password" | ||
v-model="password" | ||
name="password" | ||
type="password" | ||
autocomplete="current-password" | ||
required="true" | ||
class="block w-full" | ||
/> | ||
</div> | ||
</div> | ||
|
||
<div> | ||
<StandardButton | ||
:type="'submit'" | ||
:text="'Login'" | ||
class="btn-primary mt-6 w-full justify-center" | ||
/> | ||
</div> | ||
|
||
<div v-if="showError"> | ||
<p class="text-sm text-danger">Wrong credentials or account does not exist</p> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</template> |
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,29 @@ | ||
import { mande } from 'mande' | ||
import { defineStore } from 'pinia' | ||
|
||
export const useleedauth = defineStore('leedauth', () => { | ||
async function leedlogin(payload) { | ||
try { | ||
console.log('leedlogin') | ||
const url = localStorage.getItem('url') | ||
const organizer = localStorage.getItem('organizer') | ||
const slug = localStorage.getItem('selectedEventSlug') | ||
const apiToken = localStorage.getItem('api_token') | ||
console.log(url, organizer, slug, apiToken, payload) | ||
const headers = { | ||
Authorization: `Device ${apiToken}`, | ||
Accept: 'application/json' | ||
} | ||
const api = mande(url, { headers: headers }) | ||
const response = await api.post(`/api/v1/event/${organizer}/${slug}/exhibitors/auth`, payload) | ||
console.log('here', response) | ||
return response | ||
} catch (error) { | ||
console.log(error) | ||
console.log('error') | ||
return 'wt' | ||
} | ||
} | ||
|
||
return { leedlogin } | ||
}) |
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,61 @@ | ||
import { useCameraStore } from '@/stores/camera' | ||
import { defineStore } from 'pinia' | ||
import { computed, ref } from 'vue' | ||
|
||
export const useProcessEventyayCheckInStore = defineStore('processEventyayCheckIn', () => { | ||
const cameraStore = useCameraStore() | ||
const message = ref('') | ||
const showSuccess = ref(false) | ||
const showError = ref(false) | ||
function $reset() { | ||
message.value = '' | ||
showSuccess.value = false | ||
showError.value = false | ||
} | ||
|
||
const response = computed(() => { | ||
let classType = '' | ||
if (showSuccess.value) { | ||
classType = 'text-success' | ||
} | ||
if (showError.value) { | ||
classType = 'text-danger' | ||
} | ||
return { | ||
message: message.value, | ||
class: classType | ||
} | ||
}) | ||
|
||
function showErrorMsg() { | ||
showSuccess.value = false | ||
showError.value = true | ||
} | ||
|
||
function showSuccessMsg() { | ||
showSuccess.value = true | ||
showError.value = false | ||
} | ||
|
||
async function checkIn() { | ||
const qrData = JSON.parse(cameraStore.qrCodeValue) | ||
const event = localStorage.getItem('selectedEventName') | ||
|
||
if (qrData.event === event) { | ||
console.log(cameraStore.qrCodeValue) | ||
message.value = 'Check in successful' | ||
showSuccessMsg() | ||
} else { | ||
console.log(qrData.event) | ||
console.log(event) | ||
message.value = 'Invalid Event' | ||
showErrorMsg() | ||
} | ||
} | ||
|
||
return { | ||
response, | ||
checkIn, | ||
$reset | ||
} | ||
}) |