Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-foodcoops
third-party
Commits
31c21101
Commit
31c21101
authored
Sep 24, 2024
by
Yvon Kerdoncuff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change password : show errors in browser with explanations
parent
f8d6b785
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
12 deletions
+22
-12
models.py
members/models.py
+13
-3
views.py
members/views.py
+7
-3
change_password_availibility.html
templates/website/change_password_availibility.html
+2
-6
No files found.
members/models.py
View file @
31c21101
...
...
@@ -35,7 +35,7 @@ class CagetteMember(models.Model):
@staticmethod
def
get_new_password_link
(
data
):
link_elts
=
{}
result
=
{}
if
'email'
in
data
:
email
=
data
[
'email'
]
.
strip
()
validator
=
validators
.
EmailValidator
()
...
...
@@ -46,9 +46,19 @@ class CagetteMember(models.Model):
m_res
=
api
.
search_read
(
'res.partner'
,
cond
,
[
'id'
])
if
m_res
and
'id'
in
m_res
[
0
]:
res
=
api
.
execute
(
'res.partner'
,
'send_new_password_email'
,
[
m_res
[
0
][
'id'
]])
if
'error'
in
res
:
result
[
'error'
]
=
res
[
'error'
]
else
:
result
[
'error'
]
=
'get_new_password_link django error : res_partner not found'
except
Exception
as
e
:
link_elts
[
'error'
]
=
' '
.
join
(
e
.
messages
)
return
link_elts
result
[
'error'
]
=
'get_new_password_link error while calling odoo api : '
+
str
(
e
)
if
"Only users with the following access level are currently allowed to do that"
in
str
(
e
):
result
[
'error'
]
+=
(
" Il s'agit peut-être d'un problème de permissions de l'utilisateur api : "
"donnez lui le droit Administration/Settings (Configuration en français)"
)
else
:
result
[
'error'
]
=
'get_new_password_link django error : no email in data'
return
result
@staticmethod
def
set_new_password
(
received_pwd
,
token
):
...
...
members/views.py
View file @
31c21101
...
...
@@ -419,14 +419,18 @@ def create_from_csv(request):
def
ask_for_new_password
(
request
):
succeeded
=
False
res
=
{
'succeeded'
:
None
}
res
=
{}
try
:
data
=
json
.
loads
(
request
.
body
.
decode
())
CagetteMember
.
get_new_password_link
(
data
)
result
=
CagetteMember
.
get_new_password_link
(
data
)
if
'error'
in
result
:
res
[
'error'
]
=
result
[
'error'
]
else
:
succeeded
=
True
except
Exception
as
e
:
coop_logger
.
error
(
"ask_for_new_password :
%
s"
,
str
(
e
))
res
[
'error'
]
=
str
(
e
)
res
[
'error'
]
=
'ask_for_new_password django error : '
+
str
(
e
)
res
[
'succeeded'
]
=
succeeded
if
succeeded
is
True
:
...
...
templates/website/change_password_availibility.html
View file @
31c21101
...
...
@@ -65,15 +65,11 @@
xhr
.
onreadystatechange
=
function
()
{
//readyState => (0,UNSENT), (1,OPENED), (2, HEADER_RECEIVED), (3, LOADING), (4, DONE)
if
(
this
.
readyState
==
4
)
{
if
(
this
.
status
==
200
)
{
const
response
=
JSON
.
parse
(
xhr
.
response
);
if
(
response
.
succeeded
===
true
)
{
if
(
this
.
status
==
200
&&
response
.
succeeded
===
true
)
{
alert
(
"Un email vient de vous être envoyé à l'adresse indiquée pour réinitialiser le mot de passe."
);
}
else
{
alert
(
"Il n'a pas été possible de générer un mail pour réinitialiser le mot de passe correspondant à cette adresse."
);
}
}
else
{
alert
(
"Une erreur est survenue pendant le traitement de la demande."
);
alert
(
"Une erreur est survenue pendant le traitement de la demande : "
+
response
.
error
);
}
ask_pwd_span
.
textContent
=
"Changer de mot de passe"
;
}
...
...
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