opencart checking if islogged admin - admin

I'm creating a page on admin -the page basically register a new user- and it has accessible without user been logged.
But somehow opencart sees that user is not logged and redirects to login page.
Does anybody know where opencart checks it? This way I can put an exception.
Many thanks
DM

Someone answered me somewhere else, so I will share it here:
Straight from the admin/index.php, the check validation is initialized.
// Login
$controller->addPreAction(new Action('common/login/check'));

Related

Django-allauth: myappdomain.com/accounts/login redirects to myappdomain.com

I'm following the tutorial here: http://www.sarahhagstrom.com/page/3/
I'm at the part where we go to myappdomain.com/accounts/login to see the login page, but for me the website is just redirecting back to the index page at myappdomain.com. Does anybody know what the issue might be? Thanks.
I had a similar problem and the issue was that I was already logged in as admin.
Go to the admin area and make sure you logout, then you should be able to go to myappdomain.com/accounts/login page enter your details here and get redirected only after you login.

prevent django-allauth login on confirm email

I am using django-allauth to handle user registration in my site. I noticed a strange behavior. Let's say I register a new user in the site. That user get's a new email with a link to click. When the user clicks that link it takes him in the confirm page. There the user clicks the confirm button and users email is confirmed.
The problem is that as as a side effect the user is also logged in. I don't want that. This only happens only the first time I visit that page. If I visit that page again and confirms the email the user does not log in automatically.
My question is how can I prevent the user log in even in the first time he confirms the email. I searched the documentation but couldn't not find any setting to prevent this. Also I looked in the source code of ConfirmEmailView and I can't see a way to turn off this behavior besides manually commenting this line
resp = self.login_on_confirm(confirmation)
Update:
I think I found a workaround to the problem without having to fork or whatever. I just copied that class in my own views file trying to make sure I also imported all the other dependencies that are needed. Then I just deleted that call on login and the function that it calls. I hope I did a good job with that. After that in my urls.py, right before the imports for allauth, I copied the line that is used for confirm-email and redirected it to my own view. And now it looks like this
url(r'^accounts/confirm-email/(?P<key>\w+)/$', 'userprofile.views.confirm_email',
name="account_confirm_email"),
Seems a bit hackish but it seems to work well. I hope someone comes up with a better solution.
There is an option on the configuration ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION. It is True by default. Set it to False.
ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = False
looking at the ConfirmEmailView from here one can see that login is done only if LOGIN_ON_EMAIL_CONFIRMATION is true. In order to prevent login on email confirmation you should set LOGIN_ON_EMAIL_CONFIRMATION to False in settings.py.

Django admin/frontend authentication issue

I am developing an application using Django 1.4. When I log into admin site in another tab in the browser, the application interface in which I am already logged in automatically logs out. Please help me in solving this issue. The browser I am using is Firefox. Thanks in advance.
Admin is also a user in django. So, you can't have more than one user logged in at the same time in the same browser, can you? Try the same scenario on facebook. This is what it is. You re fine, there's no problem.
On the side note, if you are just getting started with your project use Django 1.5.
Well you cannot log into the same website with different login ids simultaneously until and unless you dont use some plugins for this feature or you are opening different ids in the incognito window.
Since admin is a superuser(still a user), hence you cannot open a multiple django accounts in the same browser. One account will be logged out in order to open the other one. This is no issue. Happy coding.
The Django admin site is just another page of your Django main website. Say if you have foo.com, then foo.com/admin/ shows you the admin portal.
And we already know that two users cannot be simultaneously logged in to the same website from the same browser.
So, you can test on your foo.com site, being an admin user itself. Experience on the Django website for any user will be same, it doesn't change with user being a staff member or superuser. Only admin site has different permissions based on these factors.
In this case, you'll be able to use both the main site, as well as admin portal.
But if you really want to use different user accounts for admin site and main site, then you should either use different browsers or Private window in Firefox.

Using the django admin's site authentication in a non-admin view

I am writing a simple django app to manage pages on a website.
The pages are created through the admin site and can be previewed using the 'view on site' function.
Each page has a 'published' boolean that determines whether the view that displays pages should show it on site.
Of course, once I change the view to respect 'published' the admin page's 'view on site' link will not show the page either.
But I want to be able to preview unpublished pages during the editing process.
So I decided to change the view to check whether there is an authenticated user associated with the request.
For example:
if request.user.is_authenticated() and request.user.is_staff:
manager=Pages.objects #returns all pages
else:
manager=Pages.live #only returns published pages
Then the appropriate manager is passed to get_object_or_404 along with the page_id captured from the URL
However, in the view, user is always Anonymous even when a user who is authenticated with the admin site clicks the 'view on site' link.
So the 'live' manager always gets used and I have the same result as before: 404 when unpublished pages are accessed from the admin site.
Is this the way its supposed to behave?
I really thought the session information would be inherited from the admin site's session.
I would appreciate any direction here because I may not be too clear on how this should work.
I don't need a login mechanism for the site so I was hoping to piggyback off the admin's login to get the ability to view unpublished pages in the admin.
Thanks
The problem is gone.
Now, if I am logged into admin I can view unpublished pages otherwise I get a 404 error.
Unfortunately, I'm not sure why it started working.
I ran some package updates (neither django nor Firefox was among them) and had to restart my (archlinux) machine.
When I restarted the django develpment server and tested the function again, all was well.
I suspect Firefox was the culprit but that's only a guess.
Anyway, thanks to anyone who gave the issue some thought.
I can stop pulling my hair out now.

How do I dynamically create new pages in a Django wiki?

I am creating a wiki in Django where users should be able to register, login, create pages and other users who also login should be able to see all created pages and then either create new pages or edit existing ones.
I have already created registration and login pages and I am fine with creating and editing content on pages. My question is - do any of you (who know Django) know how I can implement the create new pages into my site? I think it will be in a "form" form where you then specify the URL, title, and content of the new page, but how do you actually create the new pages then and be able to view all created pages to any user?
I am stuck at this wall and any help would be appreciated!
At the time of page create with the form that you mentioned, if the user is logged in, you will want to store the user ID as a foreign key in your page Model. Then when you go to display created pages for a specific user, you just follow the relationship.
This was posted a long time ago, so you will probably just want to use this Django App as it solves all of this for you, in one beautiful package:
https://github.com/benjaoming/django-wiki
Have you seen the tutorial here? http://showmedo.com/videotutorials/video?name=1100000
I built a wiki with that tutorial - I think even if it doesn't answer your question may still point you in the right direction. Hope it helps!