Skip to content

Commit

Permalink
fix terms and conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
juanbroder24 committed Feb 25, 2025
1 parent e847c05 commit e7ab2a0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
12 changes: 10 additions & 2 deletions app/Http/Controllers/Auth/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ protected function create(Request $request)
'role_id' => 'required|exists:roles,id',
]);


$latestTermsVersion = $this->terms->getLatestTermsVersion();
if (! $$latestTermsVersion) {
throw new HttpException(Response::HTTP_FORBIDDEN, 'No terms and conditions found');
}

$adminUser = $request->user();

$adminRole = $adminUser->roles->first();
Expand All @@ -67,7 +71,11 @@ protected function create(Request $request)

$this->checkRoleCanBeAssigned($adminRole, $role);

$user = $this->users->createUser($request->all());
$user = $this->users->createUser(array_merge($request->all(), [
'terms_version' => $latestTermsVersion,
'accepted_agreement' => true,
]));


$user->notify(new AdminUserNeedsConfirmation(new UserConfirmationToken($user->confirmation_code)));

Expand Down
7 changes: 6 additions & 1 deletion app/Repositories/Access/User/UserProfileRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ class UserProfileRepository extends Repository

protected $users;


public function create(int $userId, $data)
{
$userProfileData = [
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
'accepted_agreement' => true,
];

if (isset($data['country_code'])) {
Expand All @@ -39,6 +40,10 @@ public function create(int $userId, $data)
if (isset($data['api_used_in'])) {
$userProfileData['api_used_in'] = $data['api_used_in'];
}
if (isset($data['terms_version'])) {
$userProfileData['terms_version'] = $data['terms_version'];
}



$userProfile = new UserProfile($userProfileData);
Expand Down
16 changes: 11 additions & 5 deletions resources/assets/js/pages/auth/register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@
<div class="register_form-bottom">
<p class="text-center mt-5 mb-0 bottom-text">
{{ $t('register_form.sign_up_agreement') }}
<b-link @click="sawTerms = true" :to="{ name: 'legal_.terms', params: {} }" target="_blank" class="underlined-link font-weight-normal">
<b-link :to="{ name: 'legal_.terms', params: {} }" target="_blank" class="underlined-link font-weight-normal">
{{ $t('register_form.terms_conditions') }}
</b-link>
</p>
<div class="form-group mb-5">
<!-- Submit Button -->
<v-button :loading="form.busy" :disabled="!sawTerms" class="btn-primary btn btn-lg w-100">
<v-button :loading="form.busy" :disabled="!isFormComplete" @click="checkTerms" class="btn-primary btn btn-lg w-100">
{{ $t('register_form.create_account') }}
</v-button>
</div>
Expand Down Expand Up @@ -262,7 +262,7 @@ export default {
},
methods: {
async register () {
async register() {
// Register the user.
const { data } = await this.form.post('/api/register')
Expand All @@ -279,6 +279,9 @@ export default {
}).catch(swal.noop)
}
},
async checkTerms() {
this.sawTerms = true
},
fbLogin () {
FB.login(async (response) => {
if (response.status === 'connected') {
Expand Down Expand Up @@ -310,7 +313,7 @@ export default {
} else {
this.$router.push({ name: 'home' })
}
},
}
},
created () {
const countries = require('country-list')()
Expand All @@ -319,7 +322,10 @@ export default {
computed: {
...mapGetters({
user: 'auth/user'
})
}),
isFormComplete() {
return this.form.first_name && this.form.last_name && this.form.email && this.form.password && this.form.password_confirmation && this.form.country_code && this.form.organisation && this.form.industry_type
}
}
}
</script>
Expand Down

0 comments on commit e7ab2a0

Please sign in to comment.