3

My client has a private Craft site only accessible to their employees. To access the site they all use the same username and password on a front-end login form. They are now wanting to link to this site from their intranet and have the username and password form values auto-populated (only when accessed from the intranet). I have come up with a way using a Craft route (example.com/login/user/username/password/actualpassword) and craft.request.segment to auto-populate the form input values. This works but I was wondering if anyone else has a solution that doesn't require the password being in the URL.

Thanks!

2 Answers 2

3

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 type="password" value="{{ pass|default('') }} name="password" />
1
  • Thanks for the response @aran . I think what I was actually looking for was {% if craft.request.getUrlReferrer == "intranet.net" %} since I want to fill the password for users who are visiting the site via a link from the intranet. Thanks for sending me down this path!
    – nickespi
    Commented Jul 29, 2015 at 19:42
1

The above answer is great, but I'd just like to add that if the client site is public, and the company have a set of internal static IPs that users would always be accessing it from then I would add an IP check to the if statement.

By using only getUrl() someone accessing the site could simply add an entry to their host file to use that URL, and the login box would be auto populated. I realise that may be a fringe case, but you can never be too careful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.