Answers.Body: <p><code>{% requireLogin %}</code> is intended for use with your own login form on the frontend rather than the standard /admin one. From the docs for <a href="https://craftcms.com/docs/config-settings#loginPath" rel="nofollow noreferrer">loginPath</a>:</p>
  
  <blockquote>
    <p><a href="https://craftcms.com/docs/config-settings#loginPath" rel="nofollow noreferrer">The URI Craft should use for user login on the front-end.</a></p>
  </blockquote>
  
  <p>Which means you create your own frontend login form, and set that as the <code>loginPath</code>. As you don't have that, it's defaulting to the default login instead, which redirects users to the admin dashboard instead of the page they were on.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-11T15:58:31.583Z
Answers.Text: Clive, I think you can remove a ? or two :-)
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-11T15:51:37.747Z
Answers.LastActivityDate: 2017-01-12T14:07:07.350Z
Answers.LastEditDate: 2017-01-12T14:07:07.350Z
Answers.UserDisplayName: Clive Portman
Body: <p>I'm trying to password protect a staging site. So I've put a {% requireLogin %} at the top of my _layout.html inside of a conditional tag. It's working except the redirect after login always goes to the dashboard instead of the original page. What am I doing wrong?</p>
  
  <p>I'm aware of the possibility of using htaccess protection, but I think doing it the "Craft way" is nicer.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-17T14:26:55.560Z
Comments.Text: What version of Craft are you using (Personal Client or Pro)? Is your login form on the front end? Or are you using the standard /admin control panel login?
Comments.UserDisplayName: Steve Rowling
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-17T15:44:59.263Z
Comments.Text: Be sure you're testing with a user account that doesn't have CP access as well.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-18T15:11:25.040Z
Comments.Text: I'm using the Pro-Version and the standard /admin login.
  
  So it's not supposed to work for users with CP access as well? Would be nice if that was configurable.
Comments.UserDisplayName: Andreas
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-11T23:04:06.807Z
Comments.Text: Are you visiting the site without "www" and have "www" as part of your siteUrl in settings or vice versa? I once had a redirect like you are describing and think that was the cause.
Comments.UserDisplayName: Wolfram Gehring
Tags: <redirect><password><login>
Title: Password protect whole staging site. Redirect to original page not working
ThreadText: # Password protect whole staging site. Redirect to original page not working
  
  (Asked by: username_0 on 2015-03-17)
  
  I'm trying to password protect a staging site. So I've put a {% requireLogin %} at the top of my \_layout.html inside of a conditional tag. It's working except the redirect after login always goes to the dashboard instead of the original page. What am I doing wrong?
  
  I'm aware of the possibility of using htaccess protection, but I think doing it the "Craft way" is nicer.
  
  **Tags:** redirect, password, login
  
  > **Comments:**
  > **username_1**: What version of Craft are you using (Personal Client or Pro)? Is your login form on the front end? Or are you using the standard /admin control panel login?  
  > **username_2**: Be sure you're testing with a user account that doesn't have CP access as well.  
  > **username_0**: I'm using the Pro-Version and the standard /admin login.  So it's not supposed to work for users with CP access as well? Would be nice if that was configurable.  
  > **username_3**: Are you visiting the site without "www" and have "www" as part of your siteUrl in settings or vice versa? I once had a redirect like you are describing and think that was the cause.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_4 on 2017-01-11. Score: 2
  
  `{% requireLogin %}` is intended for use with your own login form on the frontend rather than the standard /admin one. From the docs for [loginPath](https://craftcms.com/docs/config-settings#loginPath):
  
  > [The URI Craft should use for user login on the front-end.](https://craftcms.com/docs/config-settings#loginPath)
  
  Which means you create your own frontend login form, and set that as the `loginPath`. As you don't have that, it's defaulting to the default login instead, which redirects users to the admin dashboard instead of the page they were on.
  
  > **Comments:**
  > **username_5**: username_4, I think you can remove a ? or two :-)  
  
  ---
  
  