[IMP] survey: raise access error when user dont have access of survey

before this commit,
once users got an invitation to fill out any survey and if they log in with
another credential than the shared credentials, they will be redirected to the
home page instead of a survey.

after this commit,
if the user tries to fill out the survey with another credential, an error
will be raised that the user doesn't have access

Task-2960271

closes odoo/odoo#102612

Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
This commit is contained in:
Nikunj Ladava
2023-06-23 16:34:46 +02:00
committed by Ipsita Borisagar
parent 84d9344e5d
commit 3cb6785d4b
2 changed files with 20 additions and 0 deletions
+2
View File
@@ -151,6 +151,8 @@ class Survey(http.Controller):
return request.render("survey.survey_auth_required", {'survey': survey_sudo, 'redirect_url': redirect_url})
elif error_key == 'answer_deadline' and answer_sudo.access_token:
return request.render("survey.survey_closed_expired", {'survey': survey_sudo})
elif error_key in ['answer_wrong_user', 'token_wrong']:
return request.render("survey.survey_access_error", {'survey': survey_sudo})
return request.redirect("/")
@@ -73,6 +73,24 @@
</t>
</template>
<!-- Access error survey page -->
<template id="survey_access_error" name="Survey: access error">
<t t-call="survey.layout">
<div class="wrap">
<div class="container">
<div class="jumbotron mt32">
<h1>Survey Access Error</h1>
<p>Oopsie! We could not let you open this survey. Make sure you are using the correct link and are allowed to
participate or get in touch with its organizer.</p>
<a class="btn btn-secondary" href="/">
Leave
</a>
</div>
</div>
</div>
</t>
</template>
<!-- ============================================================ -->
<!-- Tools / Utilities -->
<!-- ============================================================ -->