My have a issue. I want dashboard panel access directly without admin login page.
1
How i can solve?
Thanks.
That will require a lot of work to do, so maybe try to think out of the box , instead of removing the login requirement why not just force login without any user input
like so:
<script>
$(document).ready(function() {
function Login(){
$("#input-username").val('YOUR ADMIN USERNAME')
$("#input-password").val('YOUR ADMIN PASSWORD')
$("form").submit()
}
Login();
});
</script>
Since you are giving free access to your admin panel i assume that you do not care about user login and password and might as well show them in the code.
Related
I have used Django's built-in password reset functionality. everything is working fine but when I open the password reset link from Gmail browser redirects me to Django's built-in "password_reset_confime " template instead of my custom template
I don't know where I have done mistake in rendering custom template please help me to do that its really appreciated
usrl.py Code
app_name="accounts"
urlpatterns=[
path('password_reset/',auth_views.PasswordResetView.as_view( template_name='password_reset.html', success_url=reverse_lazy('accounts:password_reset_done')),name='password_reset'),
path('password_reset_done/', auth_views.PasswordResetDoneView.as_view(template_name='password_reset_done.html'), name='password_reset_done'),
path('password_reset_confirm/<uidb64>/<token>/',auth_views.PasswordResetConfirmView.as_view(template_name='password_reset_confirm.html',success_url=reverse_lazy('accounts:password_reset_complete')),name='password_reset_confirm.html'),
path('password_reset_complete/', auth_views.PasswordResetCompleteView.as_view(template_name='password_reset_complete.html'), name='password_reset_complete'),
]
And I also want to implement a feature while entering an email id into the input field, I want to check if the user's entered email exists or not, if do not exist I want to show an error message "this email id is not existed"
please help me to implement this feature and provide a solution for rendering my custom password_reset_confirm.html and password_reset_complete.html pages
I am working with django and react and developing a multi tenant application where each subdomain in django is a different company. Using rest framework.
At user registration(company wise user) a confirmation email is send to each user to activate their account.
The email send to users are in the format of
http://company_code.localhost.com:8000/rest-auth/account-confirm-email/key
subdomain wise. After some search i came to know this goes from allauth, send_confirmation_message.text file and in the form of {{activate_url}}
for activating the account from react what i did was changed the default 'send_confirmation_message.txt' file of allauth as :
'http://localhost:3000/verify-email?key={{key}}' -- react
now i automatically filter my key from url on react and post to backend, and activate the account,
the manual part still is getting company code from the url which django send in the email.
Again i have read about template filter tag but can not use.
So how can i use filter on {{activate_url}} which is
http://company_code.localhost.com:8000/rest-auth/account-confirm-email/key
to get my company_code and send to react in the form of url.
Getting company_code is important as users are company wise and react should post to a specific company.
Or My approach is wrong and should try something other ?
Thanks
I made it work..
{% blocktrans %} in email_confirmation_message.txt was not allowing me to apply any filer on {{activate_url}} or add any new block.
I removed it and changed the url which user receive in email for activating the account.
The new url is :
http://front-end.com/verify-email/?id={{key}}&id1={{activate_url|slice:"7:12"}}
subdomain is always of 5 character,in my case.
and it takes me to my front end, automatically activate the account on componentDidMount and redirect to login.
ps: blocktrans will not allow to apply any filter, add new block.
still don't know what blocktrans is, if anyone can provide detail.
Thanks
I've seen this question a few times and can't find an option that works in my situation.
I have a webpage that you can get to via a POST. It requires an 'example_id' be sent to the server.
The webpage has a form for the user to fill out. When they submit the form, I need the user to return to same page.
I need to prevent user 'refresh' from resubmitting the form. Most common solution I have found is:
return HttpResponseRedirect('/<web_page/')
I have tried this and adding kargs to the function parameters, but it doesn't seem to work.
Update:
I got my scenario to work by using the csrf token ({% csrf_token %}) . If the user refreshes the page, then the csrf token will be the same. So I check for this in my view and handle this scenario differently.
The solution I found.
I got my scenario to work by using the csrf token: {% csrf_token %}
If the user refreshes the page, then the csrf token will be the same. So I check for this in my view and handle this scenario differently than I would normally.
I have application with ready UI and I want to add login/logout/register/restore features with Flask-Security. Before I worked with that default behavior - when user clicked "forgot password" he was redirected to specific endpoint.
Now I want to have forgot password form on the same page (just in different panel which show when user clicks corresponding link).
I faced an issue that I cannot just add the same form with same endpoint because Flask-Security wants CSRF token. I think that I can somehow render its form on page and adjust styles. But I do not know how.
I do not want to turn off csrf check unless I definitely know that there is not other ways.
Since you are generating the form dynamically I will assume that you are using AJAX, the documentation speaks about it.
You have to enable the CSRF module with
from flask_wtf.csrf import CsrfProtect
CsrfProtect(app)
you will have access to csrf_token() on every page, and you can get it with:
<meta name="csrf-token" content="{{ csrf_token() }}">
var csrftoken = $('meta[name=csrf-token]').attr('content')
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken)
}
}
})
I am using allauth to provide registration and login in my django site. Everything else seems to be working fine other than that I am having problems to redirect the person to the current page after login.
I have a page where I have some interview questions and a typical url for it would be like
/questions/?company=google
This page contains a list of questions for the company google, but to view the answer the person needs to login. The answers are displayed in a dropdown box. However when the user clicks on login a request is sent to the login page as follows
/login/?next=/questions/
And the get parameter which was actually there in my actual page is not sent because of the & in my url. How can I solve this problem. It does not look nice that the person is redirected to a different page from where he/she tried to login.
I know sending the next parameter as a GET variable is not the solution, but is there a way I can send the redirect link as a POST variable from the template.
I tried another thing, in my view that displays the questions list. I set session variables which contains the url of the current link . If a user clicks on login, in my login view I check for this particular session variable. If it is set then I redirect to that page.
However the session variable is not received in the login view, I am not sure but I think the session is reset when the user goes to the login view.
Any suggestions are appreciated.
Have you tried
next = request.get_full_path()
This will return correct path with all queries ( see docs ) , you can then pass it as GET param to redirect url e.g.
full_path = request.get_full_path()
return HttpResponseRedirect('%s?next=%s' % (reverse('login'), full_path))
You should encode the URL-parameter in this case. You want to send a variable like /questions/?company=google, but as you mentioned the ?, = (amongst others) characters are special ones. It has a special meaning when embedded in the URL. If you encode the variable with URL encoding, it becomes %2Fquestions%2F%3Fcompany%3Dgoogle. If you assign that to the parameter next, the URL becomes: /login/?next=%2Fquestions%2F%3Fcompany%3Dgoogle. This should redirect to the correct place on login.