11
votes
Accepted
Store a redirect URI for use after login
First – your Twig syntax is a little off. Here's how you could add the current URL/request path to a link, as a query parameter p:
<a href="members/login?p={{ craft.request.path }}">Log in</...
7
votes
Locked out of my Account, how to get back in?
This is not actually my answer since it's from Andrew Welch on Twitter here: https://mobile.twitter.com/nystudio107/status/1063135843441954816
If you have access to MySQL, you can change the admin ...
6
votes
Accepted
Redirect user to the page they wanted after login
If you are using {% requireLogin %} tags, then the Craft UserSession service has a getReturnUrl() method which should give you what you want. It is accessible in your templates via craft.session....
6
votes
/admin/actions/users/login 404
What server provisioner are you using? Forge? Something else? If it's Forge, it's most likely this:
https://twitter.com/nystudio107/status/895726366477344772
Also here are some Nginx configs (with ...
5
votes
Login attempts limit
There are several config settings which should help...
maxInvalidLogins - The number of invalid login attempts Craft will allow within the specified duration before the account gets locked.
...
5
votes
Accepted
/admin/actions/users/login 404
So I looked into this a bunch more tonight to satisfy my curiosity, and here's what is happening.
The default rewrite rule that Forge is apparently adding is this:
if ($request_uri ~* "^(.*/)index\....
5
votes
How to modify the login panel
You can add a logo to the login page by uploading one to Settings → General Login Page Logo.
If you need further tweaking, you could use the Control Panel CSS plugin.
I wouldn't recommend modifying ...
4
votes
Accepted
Is there a 2-factor auth plugin?
Is there a 2-factor authentication plugin for Craft?
I've heard of one in private testing, but I'm not aware if they plan to release it publicly or not.
Until the official Craft plugin store becomes ...
4
votes
Accepted
Log in as different users in backend front end at the same time?
You can use "incognito mode" in your browser, or you use another browser or computer for this type of front end testing.
4
votes
Users are always logged out on front end
I tracked down a similar problem, and documented it here: The Case of the Missing PHP Session
I'm not sure if it'll address the issue you're having specifically, but it may give you some clue on ...
4
votes
Accepted
/login page in Craft keeps redirecting to home page. What could be causing that?
/login is the default login page for Craft (see https://craftcms.com/docs/config-settings and scroll down to the users section ). You can override it by adding something like this to your config file:
...
4
votes
No craft_users table in Database
There are so many tables that phpMyAdmin paginates them. All the tables that came after craft_tags alphabetically are on the second page, making it look like there is no craft_users table. Pagination ...
4
votes
Accepted
Save and login user in a Plugin?
Put this at the top of the file:
use craft\elements\User;
Within your function use the following code:
$user = new User();
$user->pending = true;
$user->username = $contact["login_email"];
$...
4
votes
Accepted
{% requireLogin %} not returning to original page
I may be missing something here, but you probably just want to remove the postLoginRedirect setting from the config?
You could also try adding {{ redirectInput(craft.app.user.returnUrl) }} to the form....
4
votes
Accepted
Bad Request Unable to verify your data submission and unstyled CP
There isn't really enough information here to give a full answer, but 'Bad Request Unable to verify your data submission' means that Craft is not getting supplied the correct CSRF token.
To confirm, ...
4
votes
How to modify the login panel
I solved this by adding a module that is supposed to act as a sitemodule with different functions I use over most of my projects.
Inside that module you register an asset bundle that ultimately adds a ...
3
votes
Restricted front-end access
Sounds like a custom plugin is in order.
Your plugin could add a custom {% validateUser %} Twig tag. That tag would check to see if their logged in OR check craft.request.getIpAddress() and validate ...
3
votes
Restricted front-end access
Is the physical web server inside your network as well? As mcclaskiem mentioned, check to see if the IP address is within the subnet of your network and then allow access that way.
You may want to ...
3
votes
Accepted
Sometimes getting sent to /admin/undefined after login
This happened for me when I had the LastPass browser plugin version 3.3.1. Once I upgraded to 4.1.29, the issue went away.
3
votes
Accepted
requireLogin not redirecting to login page
You should create your /login template with a custom login form. If you do that, the redirect should work as expected:
craft.session.returnUrl is set to the original URL that included the {% ...
3
votes
Accepted
Call to Craft Users Login Function from Plugin
What you're attempting to do is very doable. This should be of help to you:
https://craftcms.com/classreference/services/UsersService
You can use the Yii forward function to pass along a request to ...
3
votes
My website isn't working: "Craft does not support backtracking to this version. Please upload Craft 2750 or later."
Sounds like your database was updated but your filesystem was not - that could happen perhaps if the development version and the live version share the same database, and only the development version ...
3
votes
Protect a page with a single password?
I’ve done this a few times before and this is how I usually get it done.
Set Per Entry Password
Within Craft create a new Plain Text field for the entry you would like password protected. The ...
3
votes
Accepted
Logged in after email validation
I believe you're looking for the aptly named autoLoginAfterAccountActivation config setting.
3
votes
Accepted
Auto-login on account activation
(Not necessarily a great answer to your question, but it's in the same wheelhouse and might be handy if you're working in this area)!
I remember having issues with this myself (to be honest the ...
3
votes
Autologin destination
Okay - got to the bottom of this.
Was using the wrong setting. Should have been setPasswordSuccessPath not setPasswordSuccess!
3
votes
Accepted
setPasswordPath being ignored
Picking this up with another project, it looks like the problem was me not specifying a template path as the 'setPasswordPath' config setting. Instead, I was passing a route. I was doing this because ...
3
votes
Accepted
Log in User (Craft 3)
Documentation for this can be found in Craft's class reference.
# Login as user, by id
Craft::$app->getUser()->loginByUserId($user->id);
# Redirect
return Craft::$app->getResponse()->...
3
votes
Accepted
Limit DevMode to admin users?
The goal for enabling dev mode so I can troubleshoot things while not showing those ugly errors to anyone else.
If that's all you're looking for, there is a per-user account setting for this under ...
3
votes
Accepted
CORS preflight check failing for AJAX login form on different domain
Thanks for posting your headers, that was very helpful. I experienced a very similar problem just the other day and was able to work it out via trial and error and a whole bunch of Google/...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
login × 145users × 23
admin × 20
control-panel × 17
craft3 × 16
redirect × 15
password × 9
plugin-development × 8
session × 8
form × 7
registration × 7
authentication × 7
error × 6
frontend × 6
plugins × 5
user-profile × 5
templating × 4
config × 4
error-message × 4
htaccess × 4
security × 4
csrf × 4
php × 3
migration × 3
activation × 3