-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: add 2fa[WTEL-3405] #666
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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; |
122 changes: 122 additions & 0 deletions
122
src/modules/directory/modules/users/components/_internals/qrcode-two-factor-auth.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,122 @@ | ||
<template> | ||
<div class="qrcode-two-factor-auth"> | ||
|
||
<wt-popup | ||
v-if="isConfirmationPopup" | ||
@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="qrcode-two-factor-auth__canvas" | ||
> | ||
<qrcode-vue | ||
ref="qrcode" | ||
:value="props.url" | ||
level="H" | ||
/> | ||
</div> | ||
|
||
<div class="qrcode-two-factor-auth__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> | ||
.qrcode-two-factor-auth { | ||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
download
немає в лібі вже?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Є downloadAll
І є download для iconAction.downloadActionHint - в мене не iconAction - тому я і вирішила не юзати ту локаль)