Jul 05, 2009, 09:25 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Search via SMF or Google: modx forums all of modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
News:Read what MODx Developers say: MODx Dev. Blogs
Pages: [1]   Go Down
  Print  
Author Topic: log in user via URL?  (Read 1012 times)
0 Members and 1 Guest are viewing this topic.
leapy
Member
**
Posts: 79


« on: Nov 14, 2008, 08:45 AM »

hello

I need to run a link-checker on my dev site prior to going live. You feed the link-checker a Starting URL and off it goes finding links and checking them.

I need the link-checker to visit all pages on my site including private pages. To set things up, I created a login page specifically for the link-checking app with the alias 'linkcheck'. On this form, I call WebLogin with
Code:
&useCaptcha=`0`
.

The application will accept POST data to send with the Starting URL in order to deal with form based log-in. e.g.
http://dev.mydomain.com/linkcheck?username=test&password=testtest&rememberme=0

In MODx, this log in form just reloads without the user being logged in.

I should maybe point out that I do not want to check modx/wayfinder generated links but the content of our pages holds a number of manually entered links that need to be regularly checked for validity.

Can anyone explain how to get around this please?

Thanks

L

« Last Edit: Nov 14, 2008, 08:55 AM by leapy » Logged
bunk58
Committed to MODx
*****
Posts: 1,397


David Bunker


WWW
« Reply #1 on: Nov 14, 2008, 09:27 AM »

If you're using the standard WebLogin snippet then it accepts only $_POST data from a form, not $_GET data from a querystring.
At around line 186 of assets/snippets/weblogin/weblogin.processor.inc.php you could try changing this :
Code:
$username = $modx->db->escape(strip_tags($_POST['username']));
    $givenPassword = $modx->db->escape($_POST['password']);
    $captcha_code = isset($_POST['captcha_code'])? $_POST['captcha_code']: '';
    $rememberme = $_POST['rememberme'];
to this :
Code:
$username = $modx->db->escape(strip_tags($_REQUEST['username']));
    $givenPassword = $modx->db->escape($_REQUEST['password']);
    $captcha_code = isset($_REQUEST['captcha_code'])? $_REQUEST['captcha_code']: '';
    $rememberme = $_REQUEST['rememberme'];
I haven't tested it, so definitely make a backup!
Logged

leapy
Member
**
Posts: 79


« Reply #2 on: Nov 14, 2008, 06:53 PM »

Thanks - that appeared to work.

For the benefit of others:

a) I duplicated assets/snippets/weblogin/weblogin.processor.inc.php creating assets/snippets/weblogin/webloginLinkCheck.processor.inc.php
b) Edited webloginLinkCheck.processor.inc.php with Davids suggested changes
c) Commented out any lines referring to captcha
d) I created a duplicate WebLogin snippet called WebLoginLinkCheck.
e) Edited WebLoginLinkCheck to include webloginLinkCheck.processor.inc.php in place of weblogin.processor.inc.php
f) called WebLoginLinkCheck on the new login page (untick "show in menu")
g) only publish this non-captcha log in page for duration of link-checking and then immediately unpublish it.

L
Logged
bunk58
Committed to MODx
*****
Posts: 1,397


David Bunker


WWW
« Reply #3 on: Nov 15, 2008, 01:40 AM »

Glad it worked  Smiley
Thanks for putting the explanation to help others.
Logged

leapy
Member
**
Posts: 79


« Reply #4 on: Nov 15, 2008, 02:39 AM »

Thanks to you!

Not often I get the chance to give back :-)
Logged
BobRay
Moderator
*
Posts: 3,177



WWW
« Reply #5 on: Nov 15, 2008, 02:03 PM »

Thanks - that appeared to work.

For the benefit of others:

a) I duplicated assets/snippets/weblogin/weblogin.processor.inc.php creating assets/snippets/weblogin/webloginLinkCheck.processor.inc.php
b) Edited webloginLinkCheck.processor.inc.php with Davids suggested changes
c) Commented out any lines referring to captcha
d) I created a duplicate WebLogin snippet called WebLoginLinkCheck.
e) Edited WebLoginLinkCheck to include webloginLinkCheck.processor.inc.php in place of weblogin.processor.inc.php
f) called WebLoginLinkCheck on the new login page (untick "show in menu")
g) only publish this non-captcha log in page for duration of link-checking and then immediately unpublish it.

L

For others using this technique, the changes make the site less secure so items d and g are very important. I'd strongly recommend against make the suggested changes to the original file and leaving them in.

Logged

MODx info for newbies: http://bobsguides.com/MODx.html
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF | SMF © 2006-2008, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!