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):
...
@@ -35,7 +35,7 @@ class CagetteMember(models.Model):
@staticmethod
@staticmethod
def
get_new_password_link
(
data
):
def
get_new_password_link
(
data
):
link_elts
=
{}
result
=
{}
if
'email'
in
data
:
if
'email'
in
data
:
email
=
data
[
'email'
]
.
strip
()
email
=
data
[
'email'
]
.
strip
()
validator
=
validators
.
EmailValidator
()
validator
=
validators
.
EmailValidator
()
...
@@ -46,9 +46,19 @@ class CagetteMember(models.Model):
...
@@ -46,9 +46,19 @@ class CagetteMember(models.Model):
m_res
=
api
.
search_read
(
'res.partner'
,
cond
,
[
'id'
])
m_res
=
api
.
search_read
(
'res.partner'
,
cond
,
[
'id'
])
if
m_res
and
'id'
in
m_res
[
0
]:
if
m_res
and
'id'
in
m_res
[
0
]:
res
=
api
.
execute
(
'res.partner'
,
'send_new_password_email'
,
[
m_res
[
0
][
'id'
]])
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
:
except
Exception
as
e
:
link_elts
[
'error'
]
=
' '
.
join
(
e
.
messages
)
result
[
'error'
]
=
'get_new_password_link error while calling odoo api : '
+
str
(
e
)
return
link_elts
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
@staticmethod
def
set_new_password
(
received_pwd
,
token
):
def
set_new_password
(
received_pwd
,
token
):
...
...
members/views.py
View file @
31c21101
...
@@ -419,14 +419,18 @@ def create_from_csv(request):
...
@@ -419,14 +419,18 @@ def create_from_csv(request):
def
ask_for_new_password
(
request
):
def
ask_for_new_password
(
request
):
succeeded
=
False
succeeded
=
False
res
=
{
'succeeded'
:
None
}
res
=
{}
try
:
try
:
data
=
json
.
loads
(
request
.
body
.
decode
())
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
succeeded
=
True
except
Exception
as
e
:
except
Exception
as
e
:
coop_logger
.
error
(
"ask_for_new_password :
%
s"
,
str
(
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
res
[
'succeeded'
]
=
succeeded
if
succeeded
is
True
:
if
succeeded
is
True
:
...
...
templates/website/change_password_availibility.html
View file @
31c21101
...
@@ -65,15 +65,11 @@
...
@@ -65,15 +65,11 @@
xhr
.
onreadystatechange
=
function
()
{
xhr
.
onreadystatechange
=
function
()
{
//readyState => (0,UNSENT), (1,OPENED), (2, HEADER_RECEIVED), (3, LOADING), (4, DONE)
//readyState => (0,UNSENT), (1,OPENED), (2, HEADER_RECEIVED), (3, LOADING), (4, DONE)
if
(
this
.
readyState
==
4
)
{
if
(
this
.
readyState
==
4
)
{
if
(
this
.
status
==
200
)
{
const
response
=
JSON
.
parse
(
xhr
.
response
);
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."
);
alert
(
"Un email vient de vous être envoyé à l'adresse indiquée pour réinitialiser le mot de passe."
);
}
else
{
}
else
{
alert
(
"Il n'a pas été possible de générer un mail pour réinitialiser le mot de passe correspondant à cette adresse."
);
alert
(
"Une erreur est survenue pendant le traitement de la demande : "
+
response
.
error
);
}
}
else
{
alert
(
"Une erreur est survenue pendant le traitement de la demande."
);
}
}
ask_pwd_span
.
textContent
=
"Changer de mot de passe"
;
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