Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SMILE+
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
SMILE+
Commits
b66223d4
Commit
b66223d4
authored
1 month ago
by
Anthony ROULEAU
Browse files
Options
Downloads
Patches
Plain Diff
Correction du case dans le champ email
parent
fcb1b4c6
No related branches found
No related tags found
No related merge requests found
Pipeline
#38757
passed
1 month ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
smileplus/smile-plus-frontend/src/components/LoginButton.vue
+113
-0
113 additions, 0 deletions
smileplus/smile-plus-frontend/src/components/LoginButton.vue
with
113 additions
and
0 deletions
smileplus/smile-plus-frontend/src/components/LoginButton.vue
0 → 100644
+
113
−
0
View file @
b66223d4
<
template
>
<div>
<q-btn
v-if=
"!authStore.isAuthenticated"
flat
label=
"Connexion"
icon=
"login"
@
click=
"showLoginDialog = true"
/>
<q-btn
v-else
flat
label=
"Déconnexion"
icon=
"logout"
@
click=
"authStore.logout"
/>
<q-btn
v-if=
"authStore.isAuthenticated && userStore.user"
flat
:label=
"userStore.user.email"
icon=
"account_circle"
@
click=
"$router.push('/profile')"
/>
<q-dialog
v-model=
"showLoginDialog"
>
<q-card
style=
"min-width: 300px"
>
<q-card-section
class=
"text-h6"
>
Choisissez votre mode de connexion
</q-card-section>
<q-card-section>
<q-btn
outline
color=
"primary"
class=
"full-width q-mb-sm"
@
click=
"showLocalForm = 'login'"
>
<q-icon
name=
"person"
class=
"q-mr-sm"
/>
Connexion locale
</q-btn>
<q-btn
outline
color=
"secondary"
class=
"full-width q-mb-sm"
@
click=
"showLocalForm = 'register'"
>
<q-icon
name=
"person_add"
class=
"q-mr-sm"
/>
Créer un compte
</q-btn>
<q-btn
color=
"secondary"
class=
"full-width"
@
click=
"redirectToUniversity"
>
<q-icon
name=
"school"
class=
"q-mr-sm"
/>
Connexion universitaire
</q-btn>
</q-card-section>
<q-card-section
v-if=
"showLocalForm === 'login'"
>
<q-input
v-model=
"login.email"
label=
"Email"
type=
"email"
/>
<q-input
v-model=
"login.password"
label=
"Mot de passe"
type=
"password"
class=
"q-mt-sm"
@
keyup.enter=
"submitLogin(login.email, login.password)"
/>
<q-banner
v-if=
"errorMessage"
class=
"q-mt-md"
dense
color=
"negative"
icon=
"warning"
>
{{
errorMessage
}}
</q-banner>
</q-card-section>
<q-card-section
v-if=
"showLocalForm === 'register'"
>
<q-input
v-model=
"register.email"
label=
"Email"
type=
"email"
/>
<q-input
v-model=
"register.password"
label=
"Mot de passe"
type=
"password"
class=
"q-mt-sm"
/>
<q-input
v-model=
"register.confirmPassword"
label=
"Confirmation"
type=
"password"
@
keyup.enter=
"submitRegister"
class=
"q-mt-sm"
/>
<q-banner
v-if=
"registerError"
class=
"q-mt-md"
dense
color=
"negative"
icon=
"warning"
>
{{
registerError
}}
</q-banner>
</q-card-section>
<q-card-actions
align=
"right"
>
<q-btn
flat
label=
"Annuler"
color=
"primary"
v-close-popup
@
click=
"resetDialog"
/>
<q-btn
v-if=
"showLocalForm === 'login'"
label=
"Se connecter"
color=
"primary"
@
click=
"submitLogin(login.email, login.password)"
/>
<q-btn
v-if=
"showLocalForm === 'register'"
label=
"Créer le compte"
color=
"primary"
@
click=
"submitRegister"
/>
</q-card-actions>
</q-card>
</q-dialog>
</div>
</
template
>
<
script
setup
>
import
{
ref
}
from
'
vue
'
import
{
useAuthStore
}
from
"
@/stores/authStore.js
"
;
import
{
useUserStore
}
from
"
@/stores/userStore.js
"
import
{
Notify
}
from
'
quasar
'
const
showLoginDialog
=
ref
(
false
)
const
showLocalForm
=
ref
(
false
)
const
login
=
ref
({
email
:
''
,
password
:
''
})
const
register
=
ref
({
email
:
''
,
password
:
''
,
confirmPassword
:
''
})
const
errorMessage
=
ref
(
''
)
const
registerError
=
ref
(
''
)
const
authStore
=
useAuthStore
()
const
userStore
=
useUserStore
()
async
function
submitLogin
(
email
,
password
)
{
await
authStore
.
login
(
email
,
password
)
if
(
!
authStore
.
error
)
{
Notify
.
create
({
type
:
'
positive
'
,
message
:
'
Connexion réussi !
'
})
showLoginDialog
.
value
=
false
resetDialog
()
}
else
{
errorMessage
.
value
=
authStore
.
error
console
.
error
(
authStore
.
error
)
}
}
async
function
submitRegister
()
{
registerError
.
value
=
''
if
(
register
.
value
.
password
!==
register
.
value
.
confirmPassword
)
{
registerError
.
value
=
"
Les mots de passe ne correspondent pas.
"
return
}
try
{
await
userStore
.
register
(
register
.
value
.
email
.
toLowerCase
(),
register
.
value
.
password
)
await
submitLogin
(
register
.
value
.
email
.
toLowerCase
(),
register
.
value
.
password
)
Notify
.
create
({
type
:
'
positive
'
,
message
:
'
Compte créé avec succès !
'
})
}
catch
(
err
)
{
registerError
.
value
=
err
.
message
||
'
Erreur lors de la création du compte
'
}
}
function
redirectToUniversity
()
{
window
.
location
.
href
=
'
/Shibboleth.sso/Login
'
}
function
resetDialog
()
{
showLocalForm
.
value
=
null
login
.
value
=
{
email
:
''
,
password
:
''
}
register
.
value
=
{
email
:
''
,
password
:
''
,
confirmPassword
:
''
}
errorMessage
.
value
=
''
registerError
.
value
=
''
}
</
script
>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment