Skip to content

Commit 48d63bf

Browse files
User: Fix T&C initial language load, rename 'Register' to 'Accept Terms and Conditions' and add hide_legal_accept_checkbox setting - refs BT#22774
1 parent 7b06bd8 commit 48d63bf

File tree

14 files changed

+493
-452
lines changed

14 files changed

+493
-452
lines changed

assets/vue/components/Login.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
v-if="allowRegistration"
6767
v-t="'Sign up'"
6868
class="btn btn--primary-outline"
69-
href="/main/auth/inscription.php"
69+
href="/main/auth/registration.php"
7070
tabindex="3"
7171
/>
7272
</div>

assets/vue/components/layout/TopbarNotLoggedIn.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const menuItems = computed(() => {
5959
if (allowRegistration.value) {
6060
items.splice(2, 0, {
6161
label: t("Registration"),
62-
url: "/main/auth/inscription.php",
62+
url: "/main/auth/registration.php",
6363
})
6464
}
6565

assets/vue/composables/auth/login.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ import securityService from "../../services/securityService"
66
import { useNotification } from "../notification"
77

88
function isValidHttpUrl(string) {
9-
let url
10-
119
try {
12-
url = new URL(string)
13-
} catch (_) {
10+
const url = new URL(string)
11+
return url.protocol === "http:" || url.protocol === "https:"
12+
} catch {
1413
return false
1514
}
16-
17-
return url.protocol === "http:" || url.protocol === "https:"
1815
}
1916

2017
export function useLogin() {
@@ -26,21 +23,30 @@ export function useLogin() {
2623

2724
const isLoading = ref(false)
2825

29-
async function performLogin(payload) {
26+
async function performLogin({ login, password, _remember_me, totp = null }) {
3027
isLoading.value = true
3128

3229
try {
30+
const payload = {
31+
username: login,
32+
password,
33+
_remember_me,
34+
}
35+
if (totp) {
36+
payload.totp = totp
37+
}
38+
const returnUrl = route.query.redirect?.toString() || null
39+
if (returnUrl) {
40+
payload.returnUrl = returnUrl
41+
}
42+
3343
const responseData = await securityService.login(payload)
3444

45+
// 2FA
3546
if (responseData.requires2FA) {
3647
return { success: true, requires2FA: true }
3748
}
3849

39-
if (route.query.redirect && isValidHttpUrl(route.query.redirect.toString())) {
40-
window.location.href = route.query.redirect.toString()
41-
return
42-
}
43-
4450
if (responseData.redirect) {
4551
window.location.href = responseData.redirect
4652
return
@@ -49,19 +55,17 @@ export function useLogin() {
4955
securityStore.setUser(responseData)
5056
await platformConfigurationStore.initialize()
5157

52-
if (route.query.redirect) {
58+
if (route.query.redirect && isValidHttpUrl(route.query.redirect.toString())) {
5359
await router.replace({ path: route.query.redirect.toString() })
5460
return
5561
}
5662

5763
const setting = platformConfigurationStore.getSetting("registration.redirect_after_login")
5864
let target = "/"
59-
6065
if (setting && typeof setting === "string") {
6166
try {
6267
const map = JSON.parse(setting)
6368
const roles = responseData.roles || []
64-
6569
const getProfile = () => {
6670
if (roles.includes("ROLE_ADMIN")) return "ADMIN"
6771
if (roles.includes("ROLE_SESSION_MANAGER")) return "SESSIONADMIN"
@@ -72,10 +76,8 @@ export function useLogin() {
7276
if (roles.includes("ROLE_STUDENT")) return "STUDENT"
7377
return null
7478
}
75-
7679
const profile = getProfile()
7780
const value = profile && map[profile] ? map[profile] : ""
78-
7981
switch (value) {
8082
case "user_portal.php":
8183
case "index.php":
@@ -109,7 +111,6 @@ export function useLogin() {
109111
if (!securityStore.isAuthenticated) {
110112
return
111113
}
112-
113114
if (route.query.redirect) {
114115
await router.push({ path: route.query.redirect.toString() })
115116
} else {

0 commit comments

Comments
 (0)