Skip to content

Commit fc3c9e8

Browse files
Updated: securities setting store complete
Updated: MFA settings and profile is completed
1 parent 8456e34 commit fc3c9e8

File tree

7 files changed

+143
-1
lines changed

7 files changed

+143
-1
lines changed

Http/Controllers/Backend/UsersController.php

+2
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@ public function getProfile(Request $request): JsonResponse
500500
{
501501
try {
502502
$data['profile'] = User::query()->find(Auth::user()->id);
503+
$data['mfa_methods'] = config('settings.global.mfa_methods');
504+
$data['mfa_status'] = config('settings.global.mfa_status');
503505

504506
$response['success'] = true;
505507
$response['data'] = $data;

Models/UserBase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class UserBase extends Authenticatable
4141
"gender","country_calling_code","phone", "bio",
4242
"website","timezone",
4343
"alternate_email","avatar_url","birth",
44-
"country","country_code","last_login_at","last_login_ip",
44+
"country","country_code","is_mfa_enabled","last_login_at","last_login_ip",
4545
"remember_token", "login_otp", "api_token","api_token_used_at",
4646
"api_token_used_ip","is_active","activated_at","status",
4747
"affiliate_code","affiliate_code_used_at","mfa_code_expired_at",

Vue/vaahtwo/pages/profile/Profile.vue

+30
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<script setup>
22
import {onMounted, reactive, ref} from "vue";
3+
4+
import { vaah } from '../../vaahvue/pinia/vaah'
35
import {useRoute} from 'vue-router';
46
57
import {useProfileStore} from '../../stores/store-profile'
@@ -9,6 +11,7 @@ import FileUploader from "./components/FileUploader.vue";
911
const store = useProfileStore();
1012
const route = useRoute();
1113
const root = useRootStore();
14+
const useVaah = vaah();
1215
1316
import { useConfirm } from "primevue/useconfirm";
1417
const confirm = useConfirm();
@@ -217,6 +220,33 @@ onMounted(async () => {
217220
</template>
218221
</Card>
219222
</div>
223+
<div class="col-4" v-if="store.list && store.list.mfa_status === 'user-will-have-option'">
224+
<h5 class="mb-2">Multi-Factor Authentication</h5>
225+
<p class="text-sm">Multi-factor Authentication (MFA) is an authentication method that
226+
requires the user to provide two or more verification factors to gain access to a resource.</p>
227+
</div>
228+
<div class="col-5 p-fluid mt-3" v-if="store.list && store.list.mfa_status === 'user-will-have-option'">
229+
<Card class="form">
230+
<template #content>
231+
<div class="p-float-label"
232+
v-if=" store.mfa_methods"
233+
v-for="method in store.mfa_methods">
234+
<Checkbox class="flex"
235+
:data-testid="'profile-'+method"
236+
inputId="mfa-method"
237+
v-model="store.list.mfa_methods"
238+
:value="method" />
239+
<label class="ml-2" for="mfa-method">{{ useVaah.toLabel(method) }}</label>
240+
</div>
241+
</template>
242+
<template #footer>
243+
<Button label="Save MFA"
244+
data-testid="profile-save_mfa"
245+
@click="store.storeProfile()"
246+
class="w-max p-button-sm"/>
247+
</template>
248+
</Card>
249+
</div>
220250
<div class="col-4">
221251
<h5 class="mb-2">Password</h5>
222252
<p class="text-sm">After a successful password update, you will be redirected to the login page where you can log in with your new password.</p>

Vue/vaahtwo/pages/settings/general/Index.vue

+12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useGeneralStore } from "../../../stores/settings/store-general_setting"
55
import draggable from 'vuedraggable';
66
import { vaah } from '../../../vaahvue/pinia/vaah';
77
import SiteSettings from './components/SiteSettings.vue';
8+
import Securities from './components/Securities.vue';
89
import DateTime from './components/DateTime.vue';
910
import SocialMediaLink from './components/SocialMediaLink.vue';
1011
import Script from './components/Scripts.vue';
@@ -61,6 +62,17 @@ onMounted(async () => {
6162
<SiteSettings />
6263
</AccordionTab>
6364

65+
<AccordionTab>
66+
<template #header>
67+
<div class="w-full">
68+
<h5 class="font-semibold text-sm">Securities</h5>
69+
<p class="text-color-secondary text-xs">Enable and choose multiple methods of authentication</p>
70+
</div>
71+
</template>
72+
73+
<Securities />
74+
</AccordionTab>
75+
6476
<AccordionTab>
6577
<template #header>
6678
<div class="w-full">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<script setup>
2+
import { useGeneralStore } from "../../../../stores/settings/store-general_setting";
3+
4+
const store = useGeneralStore();
5+
</script>
6+
7+
<template>
8+
<div v-if="store && store.list">
9+
<div class="grid">
10+
<div class="col-12">
11+
<h4 class="font-semibold text-sm">Multi-Factor Authentication</h4>
12+
<p class="text-color-secondary text-xs font-semibold">Require a email OTP, sms OTP or authenticator app verification when you login with password.</p>
13+
</div>
14+
<div class="col-12">
15+
<div class="field">
16+
<div class="field-radiobutton">
17+
<RadioButton inputId="mfa-option-1"
18+
name="mfa"
19+
:data-testid="'general-securities_status_'+store.list.mfa_status"
20+
value="disable"
21+
v-model="store.list.mfa_status" />
22+
<label for="mfa-option-1">Disable</label>
23+
</div>
24+
<div class="field-radiobutton">
25+
<RadioButton inputId="mfa-option-2"
26+
name="mfa"
27+
:data-testid="'general-securities_status_'+store.list.mfa_status"
28+
value="all-users"
29+
v-model="store.list.mfa_status" />
30+
<label for="mfa-option-2">Enable for all users</label>
31+
</div>
32+
<div class="field-radiobutton">
33+
<RadioButton inputId="mfa-option-3"
34+
name="mfa"
35+
:data-testid="'general-securities_status_'+store.list.mfa_status"
36+
value="user-will-have-option"
37+
v-model="store.list.mfa_status" />
38+
<label for="mfa-option-3">Users will have option to enable it</label>
39+
</div>
40+
</div>
41+
<div class="field">
42+
<h5 class="mb-3 font-semibold text-sm">MFA Methods</h5>
43+
<div class="field-checkbox">
44+
<Checkbox :disabled="store.list.mfa_status === 'disable'"
45+
:data-testid="'general-securities_status_'+store.list.mfa_methods"
46+
inputId="binary1" class="is-small"
47+
v-model="store.list.mfa_methods"
48+
value="email-otp-verification" />
49+
<label for="binary1">Email OTP Verification</label>
50+
</div>
51+
<div class="field-checkbox">
52+
<Checkbox disabled inputId="binary2" class="is-small"
53+
:data-testid="'general-securities_status_'+store.list.mfa_methods"
54+
v-model="store.list.mfa_methods"
55+
value="sms-otp-verification" />
56+
<label for="binary2">SMS OTP Verification</label>
57+
</div>
58+
<div class="field-checkbox">
59+
<Checkbox disabled inputId="binary3"
60+
:data-testid="'general-securities_status_'+store.list.mfa_methods"
61+
class="is-small"
62+
v-model="store.list.mfa_methods"
63+
value="authenticator-app" />
64+
<label for="binary3">Authenticator App (only user can enable this)</label>
65+
</div>
66+
</div>
67+
68+
<div class="field">
69+
<InputSwitch inputId="switch1"
70+
data-testid="general-securities_status_is_new_device"
71+
v-model="store.list.is_new_device_verification_enabled"/>
72+
<label for="switch1">We will prompt for additional verification when you log in from a new device or browser.</label>
73+
</div>
74+
75+
<Button label="Save"
76+
icon="pi pi-save"
77+
data-testid="general-securities_save"
78+
@click="store.storeSecuritySettings()"
79+
class="p-button-sm"
80+
/>
81+
</div>
82+
</div>
83+
</div>
84+
</template>

Vue/vaahtwo/stores/settings/store-general_setting.js

+12
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,18 @@ export const useGeneralStore = defineStore({
205205
this.getList();
206206
},
207207
//---------------------------------------------------------------------
208+
async storeSecuritySettings () {
209+
let options = {
210+
method: 'post',
211+
};
212+
213+
options.params = { list: this.list };
214+
215+
let ajax_url = this.ajax_url+'/store/site/settings';
216+
await vaah().ajax(ajax_url, null, options);
217+
218+
},
219+
//---------------------------------------------------------------------
208220
expandAll() {
209221
let accordionTabs = document.getElementById('accordionTabContainer').children.length;
210222
for (let i = 0; i <= accordionTabs; i++) {

Vue/vaahtwo/stores/store-profile.js

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const useProfileStore = defineStore({
1212
assets: null,
1313
list: null,
1414
profile: null,
15+
mfa_methods: null,
1516
active_item:null,
1617
assets_is_fetching: true,
1718
base_url: base_url,
@@ -82,6 +83,7 @@ export const useProfileStore = defineStore({
8283
if(data)
8384
{
8485
this.list = data;
86+
this.mfa_methods=data.mfa_methods;
8587
this.profile = data.profile;
8688

8789
}

0 commit comments

Comments
 (0)