Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
vidjil
vidjil
Commits
9b1938ae
Commit
9b1938ae
authored
Oct 12, 2018
by
Mikaël Salson
Browse files
Revert "Merge branch 'feature-s/1682-allow-user-to-modify-password' into 'dev'"
This reverts merge request
!196
parent
b79d06ff
Pipeline
#43926
passed with stages
in 5 minutes and 1 second
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
server/web2py/applications/vidjil/controllers/user.py
View file @
9b1938ae
...
...
@@ -57,32 +57,30 @@ def index():
reverse
=
reverse
)
def
edit
():
if
auth
.
can_modify_user
(
int
(
request
.
vars
[
'id'
])
):
if
auth
.
is_admin
(
):
user
=
db
.
auth_user
[
request
.
vars
[
"id"
]]
return
dict
(
message
=
T
(
"Edit user"
),
user
=
user
)
return
error_message
(
ACCESS_DENIED
)
def
edit_form
():
if
auth
.
can_modify_user
(
int
(
request
.
vars
[
'id'
])
):
error
=
[]
if
auth
.
is_admin
(
):
error
=
""
if
request
.
vars
[
"first_name"
]
==
""
:
error
.
append
(
"first name needed"
)
error
+=
"first name needed
,
"
if
request
.
vars
[
"last_name"
]
==
""
:
error
.
append
(
"last name needed"
)
error
+=
"last name needed
,
"
if
request
.
vars
[
"email"
]
==
""
:
error
.
append
(
"email cannot be empty"
)
error
+=
"email cannot be empty"
elif
not
re
.
match
(
r
"[^@]+@[^@]+\.[^@]+"
,
request
.
vars
[
"email"
]):
error
.
append
(
"incorrect email format"
)
error
+=
"incorrect email format"
if
request
.
vars
[
"password"
]
!=
""
:
if
request
.
vars
[
"confirm_password"
]
!=
request
.
vars
[
"password"
]:
error
.
append
(
"password fields must match"
)
error
+=
"password fields must match"
else
:
password
=
db
.
auth_user
.
password
.
validate
(
request
.
vars
[
"password"
])[
0
]
if
not
password
:
error
.
append
(
"Password is too short, should be at least of length "
+
str
(
auth
.
settings
.
password_min_length
))
if
len
(
error
)
==
0
:
if
error
==
""
:
data
=
dict
(
first_name
=
request
.
vars
[
"first_name"
],
last_name
=
request
.
vars
[
"last_name"
],
email
=
request
.
vars
[
"email"
])
...
...
@@ -97,7 +95,7 @@ def edit_form():
return
gluon
.
contrib
.
simplejson
.
dumps
(
res
,
separators
=
(
','
,
':'
))
else
:
res
=
{
"success"
:
"false"
,
"message"
:
', '
.
join
(
error
)
}
res
=
{
"success"
:
"false"
,
"message"
:
error
}
log
.
error
(
res
)
return
gluon
.
contrib
.
simplejson
.
dumps
(
res
,
separators
=
(
','
,
':'
))
else
:
...
...
server/web2py/applications/vidjil/models/VidjilAuth.py
View file @
9b1938ae
...
...
@@ -310,15 +310,6 @@ class VidjilAuth(Auth):
and
(
self
.
get_permission
(
PermissionEnum
.
admin_pre_process
.
value
,
'pre_process'
,
pre_process_id
,
user
)
\
or
self
.
is_admin
(
user
))
def
can_modify_user
(
self
,
id
):
'''
Returns True if the current user can modify the user
whose ID is given as parameter
:param: id should be an integer
'''
return
self
.
is_admin
()
or
self
.
user_id
==
id
def
can_modify
(
self
,
object_of_action
,
id
,
user
=
None
):
'''
Returns True if the user can modify the object of action whose ID id id
...
...
server/web2py/applications/vidjil/models/db.py
View file @
9b1938ae
...
...
@@ -78,8 +78,6 @@ auth = VidjilAuth(db)
crud
,
service
,
plugins
=
Crud
(
db
),
Service
(),
PluginManager
()
auth
.
settings
.
password_min_length
=
6
## create all tables needed by auth if not custom tables
auth
.
define_tables
(
username
=
False
,
signature
=
False
)
...
...
server/web2py/applications/vidjil/views/db_layout.html
View file @
9b1938ae
...
...
@@ -49,7 +49,7 @@
{{if not auth.is_impersonating() :}}
{{=auth.user.first_name}} {{=auth.user.last_name}}
<a
href=
"#"
onclick=
"db.call('user/edit', {'id': '{{=auth.user_id}}'})"
><i
class=
"icon-pencil-2"
title=
"Edit my personal informations"
></i></a>
{{=auth.user.first_name}} {{=auth.user.last_name}}
{{pass}}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment