-
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.
- Loading branch information
Showing
9 changed files
with
193 additions
and
12 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
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,21 @@ | ||
import applyTransform, { notify } from '@webitel/ui-sdk/src/api/transformers/index.js'; | ||
import instance from '../../../../../app/api/instance'; | ||
|
||
const generateUrl = async ({ id }) => { | ||
const url = `users/${id}/2fa`; | ||
|
||
try { | ||
const response = await instance.post(url,{}); | ||
return applyTransform(response.data, []); | ||
} catch (err) { | ||
throw applyTransform(err, [ | ||
notify, | ||
]); | ||
} | ||
}; | ||
|
||
const Users2faAPI = { | ||
generate: generateUrl, | ||
}; | ||
|
||
export default Users2faAPI; |
123 changes: 123 additions & 0 deletions
123
src/modules/directory/modules/users/components/_internals/user-qrcode.vue
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,123 @@ | ||
<template> | ||
<div class="user-qrcode"> | ||
|
||
<wt-popup | ||
v-if="isConfirmationPopup" | ||
overflow | ||
@close="closeConfirmationPopup" | ||
> | ||
|
||
<template v-slot:title> | ||
{{ $t('reusable.warning') }} | ||
</template> | ||
|
||
<template v-slot:main> | ||
{{ $t('objects.directory.users.askingAlert') }} | ||
</template> | ||
|
||
<template v-slot:actions> | ||
<wt-button | ||
color="secondary" | ||
@click="closeConfirmationPopup" | ||
> | ||
{{ $t('vocabulary.no') }} | ||
</wt-button> | ||
|
||
<wt-button | ||
color="error" | ||
@click="regenerateUrl" | ||
> | ||
{{ $t('vocabulary.yes') }} | ||
</wt-button> | ||
</template> | ||
</wt-popup> | ||
|
||
<div | ||
ref="qrcodeContainer" | ||
class="user-qrcode__canvas" | ||
> | ||
<qrcode-vue | ||
ref="qrcode" | ||
:value="props.url" | ||
level="H" | ||
/> | ||
</div> | ||
|
||
<div class="user-qrcode__wrapper"> | ||
<wt-button | ||
color="secondary" | ||
@click="download" | ||
> | ||
{{ $t('objects.directory.users.download') }} | ||
</wt-button> | ||
|
||
<wt-button | ||
color="error" | ||
@click="openConfirmationPopup" | ||
> | ||
{{ $t('objects.directory.users.regenerate') }} | ||
</wt-button> | ||
</div> | ||
|
||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { ref } from 'vue'; | ||
import { useStore } from 'vuex'; | ||
import QrcodeVue from 'qrcode.vue'; | ||
const props = defineProps({ | ||
namespace: { | ||
type: String, | ||
}, | ||
url: { | ||
type: String, | ||
required: true, | ||
}, | ||
}); | ||
const store = useStore(); | ||
const qrcodeContainer = ref(); | ||
const isConfirmationPopup = ref(false); | ||
function download() { | ||
const canvas = qrcodeContainer.value.querySelector('canvas'); | ||
const link = document.createElement('a'); | ||
link.download = 'qr-code.png'; | ||
link.href = canvas.toDataURL('image/png'); | ||
link.click(); | ||
} | ||
async function regenerateUrl() { | ||
await store.dispatch(`${props.namespace}/REGENERATE_2FA_URL`); | ||
closeConfirmationPopup(); | ||
} | ||
function openConfirmationPopup() { | ||
isConfirmationPopup.value = true; | ||
} | ||
function closeConfirmationPopup() { | ||
isConfirmationPopup.value = false; | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.user-qrcode { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
gap: var(--spacing-sm); | ||
&__wrapper { | ||
display: flex; | ||
gap: var(--spacing-sm); | ||
} | ||
&__canvas { | ||
box-shadow: var(--elevation-5); | ||
} | ||
} | ||
</style> |
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