EvalAI icon indicating copy to clipboard operation
EvalAI copied to clipboard

Use custom email template for reset password feature

Open Ram81 opened this issue 3 years ago • 33 comments

Description

Current template for reset password functionality is


You're receiving this email because you requested a password reset for your user account at EvalAI.

Please go to the following page and choose a new password:

https://eval.ai/auth/api/password/reset/confirm/NDIzNw/5le-ad1616b4c5337004172d

Your username, in case you've forgotten: ram81

Thanks for using our site!

The EvalAI team

We should add a custom email template for reset password. A sample template is available here.

Refer the tutorial for an example: https://simpleisbetterthancomplex.com/tutorial/2016/09/19/how-to-create-password-reset-view.html

Ram81 avatar Nov 07 '20 16:11 Ram81

Hello! Would like to take this up, if it has not been assigned yet. It would be my first contribution to the project.

kishdubey avatar Nov 07 '20 17:11 kishdubey

Hi @kishdubey , Welcome to CloudCV!

Hello! Would like to take this up, if it has not been assigned yet. It would be my first contribution to the project.

Yes, you can take this up.

RishabhJain2018 avatar Nov 07 '20 17:11 RishabhJain2018

Update: Development setup is ready. Took several hours to debug docker-compose errors. Currently working on implementing the custom email template according to the template provided.

kishdubey avatar Nov 10 '20 03:11 kishdubey

Thanks @kishdubey for updating us!

RishabhJain2018 avatar Nov 10 '20 04:11 RishabhJain2018

Reset Password and Verifying Email mails have not been reaching my email in my local EvalAI environment. Is there some sort of docker email that I should be checking? In addition, I cannot seem to find the file which contains the current template shown above by @Ram81 , could I get some direction as to where it is within the codebase?

Thank you for the guidance and patience :)

kishdubey avatar Nov 10 '20 21:11 kishdubey

@kishdubey current setup is using default templates provided by the auth package. They're not stored in the repo. You can refer the tutorial mentioned in issue and I have also linked the templates location in the issue. You can edit those templates and start using them.

Ram81 avatar Nov 12 '20 06:11 Ram81

Is anyone working on this issue? If not, can I take it up?

sal2701 avatar Nov 26 '20 12:11 sal2701

@sal2701 yes, you can pick this issue up.

Ram81 avatar Nov 26 '20 15:11 Ram81

Is anyone working on this issue ? I want to solve this as a practice for gsoc 2021.

FarhanAliRaza avatar Dec 13 '20 10:12 FarhanAliRaza

@FarhanAliRaza No I am not, please go ahead. @Ram81 Can you please unassign me. Thanks

sal2701 avatar Dec 13 '20 15:12 sal2701

@Ram81 Please assign me this ..

FarhanAliRaza avatar Dec 14 '20 08:12 FarhanAliRaza

@FarhanAliRaza sure

Ram81 avatar Dec 14 '20 10:12 Ram81

Is anyone working on this issue? I would like to work on this.

Anaxagoras7 avatar Dec 30 '20 15:12 Anaxagoras7

Hey @Anaxagoras7 , It seems like no one is working on this. You can take this up! cc: @Ram81

RishabhJain2018 avatar Dec 30 '20 15:12 RishabhJain2018

Thank you @RishabhJain2018 So do I just change the layout of the mail template or is there something else I have to do?

Anaxagoras7 avatar Dec 30 '20 15:12 Anaxagoras7

I'll let @Ram81 respond to this.

RishabhJain2018 avatar Dec 30 '20 15:12 RishabhJain2018

Hello @RishabhJain2018 and @Ram81 actually I'm bit confused after checking EvalAI/evalai/urls.py file. The reason is related to this issue itself.

  1. If you'll see line 48 than we are using "allauth" for the authentication purpose and now if we'll see line 55 than we are using "django-rest-auth" for authentication. I'm not getting that part.
  2. If we'll see line 57 and 67 than in both we are checking for email verification, also I don't understand that if we are using "django-rest-auth" than why to include these url. Also in line 62 of password reset confirm that template is not directing to any template mentioned in code.
  3. The html files in EvalAI/apps/accounts/templates/account/ we are not using at anywhere than why it's mentioned there, I mean they created a big confusion when I first saw them.
  4. Now about this issue, the tutorial you have provided is using all-auth to perform and I'm not getting that after following that tutorial where can I get the "base.html" to which I have to extend. Also can you please tell me which are we using right now for the authentication, "allauth" or "django-rest-auth"
  5. Also if we are using "django-rest-auth" than they have already stopped updating this package and we should surely checkout "dj-rest-auth" as it's the same and it is more updated.

I am searching related to this issue over internet for around past 3 days, Also I'm a bit new here, I know these doubts will take some time to clear, please take your time but I'm really curious to know about this.

Thanks

lkbhitesh07 avatar Jan 01 '21 18:01 lkbhitesh07

Hi @lkbhitesh07,

  1. If you'll see line 48 than we are using "allauth" for the authentication purpose and now if we'll see line 55 than we are using "django-rest-auth" for authentication. I'm not getting that part.
  2. If we'll see line 57 and 67 than in both we are checking for email verification, also I don't understand that if we are using "django-rest-auth" than why to include these url. Also in line 62 of password reset confirm that template is not directing to any template mentioned in code.

I don't understand the question you are asking here. Can you reframe this? If you are concerned about both allauth and django-rest-auth urls it might be the case that when allauth was deprecated we didn't remove the urls for allauth. @RishabhJain2018 might know more about this.

  1. The html files in EvalAI/apps/accounts/templates/account/ we are not using at anywhere than why it's mentioned there, I mean they created a big confusion when I first saw them.

These are the template files that you can update or move them to some other folder and use it from there. They are not being used currently, a part of this task is to update these with new templates or remove them

  1. Now about this issue, the tutorial you have provided is using all-auth to perform and I'm not getting that after following that tutorial where can I get the "base.html" to which I have to extend. Also can you please tell me which are we using right now for the authentication, "allauth" or "django-rest-auth"

rest_auth is being used for authentication. The tutorial is just an example you might've to look up for rest_auth documentation on using custom templates.

  1. Also if we are using "django-rest-auth" than they have already stopped updating this package and we should surely checkout "dj-rest-auth" as it's the same and it is more updated.

Sure, but this is not a part of this task. We can look at it as a separate task. If you are interested you can create a issue for the task and work on it.

Ram81 avatar Jan 02 '21 16:01 Ram81

Hello @Ram81 bhaiya first of all, thanks for replying and thanks for your time,

I don't understand the question you are asking here. Can you reframe this? If you are concerned about both allauth and django-rest-auth urls it might be the case that when allauth was deprecated we didn't remove the urls for allauth. RishabhJain2018 might know more about this.

Yes actually, it's clear now. I just want to ask that can we do it in a more clear manner, because there are some url mentioned that was useful when we were using allauth . I mean as we have to shift from djang-rest-auth to dj-rest-auth I will update all the templates and remove unnecessary ones and include only urls that are needed.

I've figured out somethings on how we can complete this task and we will move this conversation on that issue, just one thing we have to add dj-rest-framework to the settings.py file, but I cannot change it as it's not there, So what should I do there?

Thanks for your time.

lkbhitesh07 avatar Jan 02 '21 21:01 lkbhitesh07

I've figured out somethings on how we can complete this task and we will move this conversation on that issue, just one thing we have to add dj-rest-framework to the settings.py file, but I cannot change it as it's not there, So what should I do there?

@lkbhitesh07 updating to dj-rest-auth is a separate task. When making changes for this issue don't update to dj-reset-auth just update/delete templates and switch to using these custom templates instead of default templates. If allauth urls are not being used you can remove those as part of the PR for this issue.

Ram81 avatar Jan 03 '21 04:01 Ram81

Ok @Ram81 bhaiya. I'm on it.

lkbhitesh07 avatar Jan 03 '21 12:01 lkbhitesh07

Update - Working on this issue as to solve it I'm looking into the forms and serializers files I hope I'll complete it by tomorrow.

Now a small doubt, as you @Ram81 said bhaiya that the current template that we recieve is of rest-auth but it's not, it is of django itself. I searched down through some files and then I got to know this.

What I figured out is, at the earlier version of rest-auth they might have linked templates to django itself, also the urls we see on our website are from the earlier version becuase in current version they have updated their urls. For eg - api/auth/password-reset to api/auth/password/reset.

This update is mainly for new contributors as they will sart contributing and will read the new documentations so they might get confused.

lkbhitesh07 avatar Jan 04 '21 00:01 lkbhitesh07

Hello @Ram81 and @RishabhJain2018 bhaiya, yesterday when I tried solving this issue on my local host it was almost done I mean I was able to change the template but was not able to pass variable to be displayed but when I restarted the whole environment it stopped working somehow. Showing "something went wrong please try again later". Screenshot from 2021-01-04 19-56-15

and showing me this error

django_1 | [pid: 90|app: 0|req: 1/2] 172.18.0.1 () {42 vars in 696 bytes} [Mon Jan 4 14:20:48 2021] OPTIONS /api/auth/password/reset/ => generated 0 bytes in 3 msecs (HTTP/1.1 200) 7 headers in 365 bytes (1 switches on core 0) django_1 | [pid: 92|app: 0|req: 2/3] 172.18.0.1 () {42 vars in 696 bytes} [Mon Jan 4 14:20:48 2021] POST /api/auth/password/reset/ => generated 21812 bytes in 273 msecs (HTTP/1.1 500) 5 headers in 177 bytes (1 switches on core 0)

Methods I performed -

customized the accounts/serializers.py file and added the custom serializer like this - `class CustomPasswordResetSerializer(PasswordResetSerializer):

def get_email_options(self):

    return {
        'subject_template_name': 'account/email/password_reset_key_subject.txt',
        'email_template_name': 'account/password_reset_email.html',
    }`

I added the password_reset_email.html file.

in settings/common.py file `REST_AUTH_SERIALIZERS = {

"USER_DETAILS_SERIALIZER": "accounts.serializers.ProfileSerializer",
"PASSWORD_RESET_SERIALIZER": "accounts.serializers.CustomPasswordResetSerializer"

}`

Methods I already tried - I tried adding api/auth/password/reset to our url file. I'm trying some more methods, if it'll work I'll let you know.

Could you please help me, I'm just confused very badly on what to do now. Thanks

lkbhitesh07 avatar Jan 04 '21 14:01 lkbhitesh07

Hi @lkbhitesh07,

The POST API call for url /api/auth/password/reset/ is throwing an Internal Server Exception HttpStatus 500

POST /api/auth/password/reset/ => generated 21812 bytes in 273 msecs (HTTP/1.1 500)

It might be because the custom serializer you wrote is throwing some exception. You can add exception handling i.e try except and some debug statements to figure out what is going wrong.

Ram81 avatar Jan 05 '21 05:01 Ram81

Hello @Ram81 I'm trying to figure out what's wrong for the past 3 days but I'm not getting anywhere, I tried to use debugger but as our environment is set up using docker so it's causing trouble there. Also, I tried to do it by python manage.py runserver and it's giving me some other errors which I tried to solve and searched on google but nothing achieved. I'm just too curious and frustrated that it worked when I first did it but now it's not working. If you get some time will you please give it a try because I've asked for this issue in several forums and tried to figure it out but I'm not getting anywhere? Thanks for your support and guidance. Also, I'm still trying to solve it and will update you for the same, in case anyone else wants to give it a try feel free to do that, I just want to know why this is happening.

UPDATE - I'm able to solve the conflict here, by changing the logging setting and getting the actual error. Now I'm working toward it, just have to look for one more problem which is the variables are not passing and the format is distorted. Thanks for all your guidance.

lkbhitesh07 avatar Jan 07 '21 23:01 lkbhitesh07

Hey! There is a PR for this issue but it isn't merged yet? Is any help required with that?

ChetanKhanna avatar Mar 18 '21 13:03 ChetanKhanna

Hi i would like contribute with this issue

olartejohn avatar Apr 01 '21 01:04 olartejohn

Is anyone working on this issue ? I want to solve this as to get a better understanding of code.

shikhar168 avatar Apr 12 '21 05:04 shikhar168

@RishabhJain2018 @Ram81 I would like to work on this issue.

shashwatdh avatar Apr 23 '21 12:04 shashwatdh

@Ram81 I'm new here, can I work on this issue? Thanks

vashuteotia123 avatar Sep 16 '21 12:09 vashuteotia123