Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCODOC_R6A06
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Paul-louis Gomis
SCODOC_R6A06
Commits
3c5117c2
Commit
3c5117c2
authored
7 months ago
by
Emmanuel Viennet
Browse files
Options
Downloads
Patches
Plain Diff
Edition compte user: améliore message erreur si cas_id dupliqué
parent
16e96c24
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/auth/models.py
+10
-11
10 additions, 11 deletions
app/auth/models.py
with
10 additions
and
11 deletions
app/auth/models.py
+
10
−
11
View file @
3c5117c2
...
...
@@ -67,14 +67,6 @@ def is_valid_user_name(user_name: str) -> bool:
)
def
is_new_cas_id
(
cas_id
:
str
)
->
bool
:
"
Check that cas_id is a valid new id (uniqueness, allow nulls)
"
if
not
cas_id
:
return
True
nb_with_this_id
=
db
.
session
.
query
(
User
).
filter_by
(
cas_id
=
cas_id
).
count
()
return
nb_with_this_id
==
0
class
User
(
UserMixin
,
ScoDocModel
):
"""
ScoDoc users, handled by Flask / SQLAlchemy
"""
...
...
@@ -435,11 +427,18 @@ class User(UserMixin, ScoDocModel):
if
cas_id
:
new_cas_id
=
cas_id
if
new_cas_id
!=
self
.
cas_id
:
if
is_new_cas_id
(
new_cas_id
):
existing
:
User
=
(
db
.
session
.
query
(
User
).
filter_by
(
cas_id
=
new_cas_id
).
first
()
if
new_cas_id
is
not
None
else
None
)
if
not
existing
:
self
.
cas_id
=
new_cas_id
else
:
log
(
f
"
User.from_dict: CAS id invalide pour
{
self
.
user_name
}
"
)
raise
ScoValueError
(
f
"
CAS id invalide pour
{
self
.
user_name
}
"
)
msg
=
f
"""
CAS id invalide pour
{
self
.
user_name
}
, déjà utilisé par
{
existing
.
user_name
}
"""
log
(
f
"
User.from_dict:
{
msg
}
"
)
raise
ScoValueError
(
msg
)
def
get_token
(
self
,
expires_in
=
3600
):
"
Un jeton pour cet user. Stocké en base, non commité.
"
...
...
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