Hot answers tagged

18 votes

Protect a page with a single password?

I've actually done this a couple of times... a very simple "password-only" page. Then there would be a large group of people who share that same password, and can gain access to that protected page. ...
user avatar
  • 23.6k
16 votes
Accepted

Auto log in user

Check out the autoLoginAfterAccountActivation config setting. To enable it, set it to true in your craft/config/general.php file: 'autoLoginAfterAccountActivation' => true
user avatar
  • 13.2k
13 votes

Protect a page with a single password?

The easiest way I have found to password protect page content is as follows: {% if craft.request.getParam('password') == 'password_you_want' %} <h2>This is your content</h2> {% else %}...
user avatar
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</...
user avatar
10 votes
Accepted

Migrated Server, Now Getting Logged Out Constantly

Most likely wherever Apache/PHP is configured to save session files doesn't exist or isn't writable. If you've got the overridePhpSessionLocation config setting set to true, then that will be in ...
user avatar
  • 66.4k
7 votes

Code for resending the activation email

I want to be able that users can enter their emailaddress in an input and that the activation link gets resend You'll need to write a plugin, which can generate activation URLs using the UsersService:...
user avatar
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....
user avatar
  • 608
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 ...
user avatar
6 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 ...
user avatar
5 votes
Accepted

cp login over https gives error

This could be a couple things: Server config .htaccess file SSL Certificate But it sounds to me like the insecure login button means those assets are not being served over SSL. How'd you confirm the ...
user avatar
  • 6,467
5 votes
Accepted

Suspended users who have never logged in

This probably works: craft.users.status('suspended').lastLoginDate(':empty:')
user avatar
  • 35.8k
5 votes

Code for resending the activation email

Go to the Users section of the Control Panel (mysite.com/admin/users/). Click on the user account that needs to be activated. Click on the settings cog on the right side (see attached image), and ...
user avatar
5 votes
Accepted

Can I disable the control panel?

Good call Brad! Not sure why that didn't occur to me :) Here's how that's done: # Kill admin access RewriteCond %{REQUEST_URI} ^(.*)/admin RewriteRule ^(.*)$ - [F,L]
user avatar
  • 281
5 votes
Accepted

Login As User from Frontend

You can call it from the front-end, but it requires the currently logged in user to be an administrator. Just point the form's hidden action input to users/impersonate and have it submit a 'userId' ...
user avatar
  • 66.4k
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. ...
user avatar
  • 23.6k
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\....
user avatar
4 votes

How do I set where the user is sent from a custom login form?

You can set a variable in your craft/config/general.php. Here is the option taken from the default config file which is located here craft/app/etc/config/defaults/general.php: Updated: /** * The ...
user avatar
4 votes
Accepted

New user registration activation timeout?

The verificationCodeDuration config setting is what you're looking for. Defaults to 24 hours.
user avatar
  • 66.4k
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 ...
user avatar
  • 66.4k
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.
user avatar
  • 35.8k
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 ...
user avatar
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 ...
user avatar
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"]; $...
user avatar
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, ...
user avatar
4 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 ...
user avatar
  • 7,160
3 votes
Accepted

Auto-populate login form when accessed via client intranet

Couldn't you set the password to a variable on the login page if it is the correct intranet url? {% if craft.request.getUrl() == "intranet.net" %} {% set pass = "password" %} {% endif %} <input ...
user avatar
  • 2,717
3 votes
Accepted

It seems /login is a reserved route - is that correct?

That is set by the loginPath config setting so yes, you can change it in your craft/config/general.php file. There are a few other configurable URLs for templates and redirects, all of which are ...
user avatar
  • 4,361
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 ...
user avatar
3 votes

Can I disable the control panel?

Nothing native in Craft that would do this, but I suppose you'd be able to .htaccess redirect all requests to your cpTrigger.
user avatar
  • 66.4k
3 votes

Front end login form with ajax

If you’re getting the {success: true} response, then the user is getting logged in successfully, and the cookie would have actually been created by that response.
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible