Cloud-CV / EvalAI

:cloud: :rocket: :bar_chart: :chart_with_upwards_trend: Evaluating state of the art in AI
https://eval.ai
Other
1.76k stars 781 forks source link

Use custom email template for reset password feature #3069

Open Ram81 opened 3 years ago

Ram81 commented 3 years ago

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

kishdubey commented 3 years ago

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

RishabhJain2018 commented 3 years ago

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.

kishdubey commented 3 years ago

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.

RishabhJain2018 commented 3 years ago

Thanks @kishdubey for updating us!

kishdubey commented 3 years ago

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 :)

Ram81 commented 3 years ago

@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.

sal2701 commented 3 years ago

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

Ram81 commented 3 years ago

@sal2701 yes, you can pick this issue up.

FarhanAliRaza commented 3 years ago

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

sal2701 commented 3 years ago

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

FarhanAliRaza commented 3 years ago

@Ram81 Please assign me this ..

Ram81 commented 3 years ago

@FarhanAliRaza sure

Anaxagoras7 commented 3 years ago

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

RishabhJain2018 commented 3 years ago

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

Anaxagoras7 commented 3 years ago

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

RishabhJain2018 commented 3 years ago

I'll let @Ram81 respond to this.

lkbhitesh07 commented 3 years ago

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

Ram81 commented 3 years ago

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.

lkbhitesh07 commented 3 years ago

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.

Ram81 commented 3 years ago

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.

lkbhitesh07 commented 3 years ago

Ok @Ram81 bhaiya. I'm on it.

lkbhitesh07 commented 3 years ago

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 commented 3 years ago

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

Ram81 commented 3 years ago

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.

lkbhitesh07 commented 3 years ago

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.

ChetanKhanna commented 3 years ago

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

olartejohn commented 3 years ago

Hi i would like contribute with this issue

shikhar168 commented 3 years ago

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

shashwatdh commented 3 years ago

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

vashuteotia123 commented 3 years ago

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

ayushvrma commented 2 years ago

@RishabhJain2018 @Ram81 Is anyone assigned on this issue, can I work on it?

gkprasanth commented 2 years ago

@Ram81 Hi, I have no knowledge about any python framework. Do you think I will be able to fix this having basic python knowledge?

PrathyushaModala commented 2 years ago

Hi @Ram81 @RishabhJain2018 Is the issue still open , Can I work on this issue??