django-login

Django Microsoft AD Authentication

谁都会走 提交于 2021-02-05 09:24:06
问题 I noticed that this question was repeated few times, but still, from all the resources, I couldn't manage to make it work properly. I'm simply trying to use Azure Active Directory authentication with my Django app. I am using this module, and I configured everything as noted in the docs. The thing is - I can't figure out where should user enter the credentials - since the module has only one url ('auth-callback/'). I can't find out how to jump to Microsoft login html page. Should I use my

Importing django.contrib.auth.urls does not play well with existing admin templates

我是研究僧i 提交于 2021-01-28 01:07:45
问题 I've been trying to follow documentation on using builtin Django templates to login/logout nonstaff users on a Django (1.9) site. In particular, I modified the urlconf by adding url('^', include('django.contrib.auth.urls')) which brings in /login and /logout endpoints and views with default template names preprogrammed. The default template names for login and logout are registration/login.html and registration/logged_out.html . The first one doesn't exist anywhere, so I assumed I should

How to prevent user to access login page in django when already logged in?

天涯浪子 提交于 2020-01-02 07:25:11
问题 In my django application, user can access login/signup pages through URL even after logged-in. How to prevent them from accessing these pages? urls.py from django.urls import path from django.contrib.auth import views as auth_views from . import views app_name = 'account' urlpatterns = [ path('signup/', views.register, name='register'), path('', auth_views.LoginView.as_view(), name='login'), ] Though I can write if-else statement for checking authenticated users in views.py , but I haven't

How can I get the django allauth signup page to show up without being at the /accounts/login url?

大憨熊 提交于 2019-12-24 00:28:33
问题 A lot of websites such as pinterest, facebook, and tumblr have their signup page at their home page. Is it possible to get the allauth login page to show on the home page rather than the /accounts/login page? 回答1: Sure can! Just route whichever url you want to go to the allauth login view from django.conf.urls import patterns, include, url from main import views from allauth.account import views as allauthviews urlpatterns = patterns('', url(r'^$', allauthviews.login), url(r'^someurl/$',

Django login with django-axes

爱⌒轻易说出口 提交于 2019-12-19 06:14:14
问题 I created a site with django. Users should be able to login. The login-view looks like this: from django.contrib.auth import authenticate, login from django.contrib.auth.models import User .... if request.method == 'POST': username = request.POST['username']#get username password = request.POST['txtPwd']# and password user = authenticate(username=username, password=password) #checking username and pwd if user is not None: if user.is_active: login(request, user) But with this "solution" i can

Django: How can i get the logged user outside of view request?

北慕城南 提交于 2019-12-19 04:51:17
问题 I have a class method (outside of a view) who needs the logged user's information. How can i retrieve the logged in user without passing the request to the method? Unfortunately i can't find nowhere a nice solution and it's not logical just not exist such a way to do it, because Django should store somewhere the logged in user. Otherwise (i believe) it would be impossible to use @login_required decorator from django.contrib.auth.decorators . Right? So if it's not possible why it's not? Why

Set all pages to require login, globally?

落花浮王杯 提交于 2019-12-18 11:41:17
问题 I want to redirect access of unauthenticated users to the login page, after which the logged-in user should be redirected to the originally requested page. According to documentation, this is easily achieved using the @user_passes_test decorator. But it seems I'd have to decorate every view, which is crazy, there are too many and it's error-prone. What is a good way to turn on this functionality globally (except for a small fixed set of views, such as login )? That is, default everything to

Django- why inbuilt auth login function not passing info about user to after successful login url

大兔子大兔子 提交于 2019-12-12 05:51:37
问题 Hi I used the django inbult auth urls and views for my project and now have finished the initial user account creation/login/reset password process. Now, the user can log in and be redirected to the after successful login url accounts/profile/. I have several doubts on the django login function. For convenience, I've copy paste the django inbuilt login function code below. @sensitive_post_parameters() @csrf_protect @never_cache def login(request, template_name='registration/login.html',

Django Login Form- Logs into the dashboard 2nd time

与世无争的帅哥 提交于 2019-12-11 19:04:03
问题 I've a login form. Whenever I sign into it for the first time, it asks me the username and password again, without showing me inavlid username and password. But when I login again with the same username and password it logs in perfectly. How is it possible? Here is my code:- {% extends "base1.html" %} {% block header %} {% endblock %} {% block content %} <div class="wrap"> <div class="content-wrap"> <a href="#" class="logo"></a> <form action ="." method = POST class="form-signin" class="well