login with token instead of password

2024-01-16 Thread ABDUL HAFEEZ
example: 
I have a model with fields username and password 
when users create account  there credentials saved in db next I want that 
*instead 
of login with password I want create token *so he can login with token not 
password

what should I do
please provide me logic steps if someone have done already

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e43d49a3-e950-4396-9f90-3b1cd6f7af0an%40googlegroups.com.


Re: login with token instead of password

2024-01-16 Thread IKT Service
Maybe try to send a token to user email, when used get that email with a
activation link, he can just click and activate the account

tir. 16. jan. 2024 kl. 16:02 skrev ABDUL HAFEEZ :

> example:
> I have a model with fields username and password
> when users create account  there credentials saved in db next I want that 
> *instead
> of login with password I want create token *so he can login with token
> not password
>
> what should I do
> please en provide me logic steps if someone have done already
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e43d49a3-e950-4396-9f90-3b1cd6f7af0an%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA7BsYjNwvTR_9Oe6O%2BS6Dfqsg77n6sy-oY9N4ubOAknoN2NWA%40mail.gmail.com.


Re: login with token instead of password

2024-01-16 Thread Ahmed Iftikhar
python manage.py startapp pincode_auth_app
# pincode_auth_app/models.py from django.contrib.auth.models import
AbstractUser from django.db import models class CustomUser(AbstractUser):
pin_code = models.CharField(max_length=4, blank=True, null=True)
***
# pincode_auth_app/admin.py from django.contrib import admin from .models
import CustomUser
admin.site.register(CustomUser)
***
python manage.py makemigrations
python manage.py migrate

# pincode_auth_app/forms.py from django import forms class
PinCodeLoginForm(forms.Form):
username = forms.CharField(max_length=150)
pin_code = forms.CharField(max_length=4, widget=forms.PasswordInput)
*
# pincode_auth_app/views.py from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login from .forms import
PinCodeLoginForm def pin_code_login(request): if request.method == 'POST':
form = PinCodeLoginForm(request.POST) if form.is_valid(): username =
form.cleaned_data['username'] pin_code = form.cleaned_data['pin_code'] user
= authenticate(request, username=username, pin_code=pin_code) if user is not
None: login(request, user) return redirect('success_page') # Redirect to a
success page else: # Authentication failed return render(request,
'login.html', {'form': form, 'error': 'Invalid username or pin code'}) else:
form = PinCodeLoginForm()
return render(request, 'login.html', {'form': form})
*
   
Pin Code Login   Login {% if error %} <
p style="color: red;">{{ error }} {% endif %}  {% csrf_token %} {{ form.as_p }} Login  

***
  # pincode_auth/urls.py from django.urls import path from
pincode_auth_app.views import pin_code_login urlpatterns = [ path(
'pin-code-login/', pin_code_login, name='pin_code_login'), # Add other URLs
as needed ]
***
# pincode_auth/urls.py from django.contrib import admin from django.urls
import path, include urlpatterns = [ path('admin/', admin.site.urls), path(
'', include('pincode_auth_app.urls')),
]


On Tue, Jan 16, 2024 at 8:02 PM ABDUL HAFEEZ  wrote:

> example:
> I have a model with fields username and password
> when users create account  there credentials saved in db next I want that 
> *instead
> of login with password I want create token *so he can login with token
> not password
>
> what should I do
> please provide me logic steps if someone have done already
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e43d49a3-e950-4396-9f90-3b1cd6f7af0an%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGAxPTyJC0x31Yr%2Bu7u4qfwmeqcsv-Z6TUW0nA6ctivUXD6jdw%40mail.gmail.com.


Re: login with token instead of password

2024-01-16 Thread 'Kasper Laudrup' via Django users
Isn't this pincode_auth_app just the same as the standard Django 
password authentication, only the password is stored in plain text and 
limited to four characters?


Maybe I'm missing something?

Kind regards,
Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3e7ec0be-1c03-42e5-a1de-18bfbb1be9b4%40stacktrace.dk.


OpenPGP_0xE5D9CAC64AAA55EB.asc
Description: OpenPGP public key


OpenPGP_signature.asc
Description: OpenPGP digital signature