relekang / django-nopassword

Authentication backend for django that uses a one time code instead of passwords

Home Page:http://django-nopassword.readthedocs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

user creation on signup

muhammad-ammar opened this issue · comments

@relekang Do i need to create the users separately? Currently it raises DoesNotExist here. I am just visiting the /accounts/login/ and it is presenting me a input field with submit button. Upon entering the username in the field i get exception as mentioned above.

That is correct. There has to be an existing user for the authentication to work. You would need to create a signup view. You can use the code generation in the signup view and ask for the users email and then create a user and call authenticate. nopassword will then send a login code if there is no keyword argument code.

Example

from django.contrib.auth import authenticate

def signup(request):
    # create user as new_user
    authenticate(username=new_user.username)
    return redirect('login')

I'm going to close this issue, but please don't hesitate to ask more questions.

@relekang Bundle of thanks for your reply and code example.