Repository: OpenEnergyPlatform/oeplatform

Issue:
Profilepage settings options
Hi @Darynarli, could you help us by making a list of the things we could have under "Settings" in the profile page? Things like a "Delete account" button, personal data, privacy, notifications, etc. We won't be able to implement all of it, at least not at first, but it could be good to have an idea of the options we want to give to the users. To help you, you could have a look at your settings section on Github to see what they have to inspire you you.


Discussion:
Hi, for me it's main functions setting page:
1. button show token
2. button edit, by clicking on which you can change the name/email/affiliation/description
3. change password button, by clicking on which you can change the password
4. button delete profile, by clicking on which you can write email for account deletion request


As discussed today, I'll also make a few suggestions:

Visible to public:

- Name (mandatory)
- Role (mandatory)
- Pronouns
- Work title or Company
- Location
- Public email address
- Bio
- URL (e.g. website)
- Social media account(s)

Private:

- Change email
- Change password
- Delete account
- Receive notifications (e.g. table review complete)
Do we need Affiliation and description ?

The description (or bio in my comment) could be an idea, but as said today, we'll have to decide with the other dev members first. What do you mean by affiliation? The company or role?
I think company, and what do you think?

From my side, I would say yes, especially if it's an easy feature to implement. 

I would also like to have the role as a feature (like moderator) but this would require more work probably. I'm not sure if the roles are defined yet @jh-RLI ?

There is a role system, but it needs to be improved and extended with new roles like the _Moderator_ role. So more work is definitely needed here.

Also, I changed my mind about the email being publicly visible by default. I think it is better to show only the username.

> There is a role system, but it needs to be improved and extended with new roles like the Moderator role. So more work is definitely needed here.

Alright.

> Also, I changed my mind about the email being publicly visible by default. I think it is better to show only the username.

We could make the email public as an option. Maybe some users want to be contacted this way?
Yes would be nice to have it as an option.
The account deletion function should be just a button to delete the account and confirm it or should they write to the email and the administrator will delete the account then? If by email, which one should they write to?
Lets discuss this in he oep-dev meeting next week. I think a button would be good.
okey, can I now make a button and next week we will discuss?

Sure 👍 
token reset button is missing

Resolving patch:
diff --git a/login/urls.py b/login/urls.py
--- a/login/urls.py
+++ b/login/urls.py
@@ -102,4 +102,5 @@
     url(r"^detach$", views.DetachView.as_view()),
     url(r"^activate/(?P<token>[\w\d\-\s]+)$", views.activate),
     url(r"^activate/$", views.ActivationNoteView.as_view(), name="activate"),
+    url(r"^reset/token$", views.token_reset, name="reset-token"),
 ]
diff --git a/login/views.py b/login/views.py
--- a/login/views.py
+++ b/login/views.py
@@ -4,15 +4,19 @@
 from django.contrib.auth.mixins import LoginRequiredMixin
 from django.contrib.auth.views import PasswordChangeView
 from django.core.exceptions import PermissionDenied
+from django.http import HttpResponse, HttpResponseForbidden
 from django.shortcuts import get_object_or_404, redirect, render
 from django.urls import reverse_lazy
 from django.views.generic import FormView, View
 from django.views.generic.edit import DeleteView, UpdateView
 
+from rest_framework.authtoken.models import Token
+
 import login.models as models
 from dataedit.models import PeerReviewManager, Table, PeerReview
 from dataedit.views import schema_whitelist
 
+
 from oeplatform.settings import UNVERSIONED_SCHEMAS
 
 from .forms import (
@@ -567,3 +571,18 @@ def activate(request, token):
         token_obj.user.save()
         token_obj.delete()
     return redirect("/user/profile/{id}".format(id=token_obj.user.id))
+
+
+def token_reset(request):
+    if request.user.is_authenticated:
+
+        user_token = get_object_or_404(
+            Token, user=request.user.id
+        )  # Get the current user's token
+        user_token.delete()  # Delete the existing token
+
+        new_token = Token.objects.create(user=request.user)
+
+        return HttpResponse(new_token)
+    else:
+        return HttpResponseForbidden("You are not authorized to reset the token.")


Test patch: