Project

General

Profile

« Previous | Next » 

Revision 43

Added by stefan over 19 years ago

Added automatic frontend redirection on login.

View differences:

trunk/wb/account/login_form.php
71 71
<form name="login" action="<?php echo WB_URL.'/account/login'.PAGE_EXTENSION; ?>" method="post">
72 72
<input type="hidden" name="username_fieldname" value="<?php echo $username_fieldname; ?>" />
73 73
<input type="hidden" name="password_fieldname" value="<?php echo $password_fieldname; ?>" />
74
<input type="hidden" name="redirect" value="<?php echo $thisApp->redirect_url;?>" />
74 75

  
75 76
<table cellpadding="5" cellspacing="0" border="0" width="90%">
76 77
<tr>
trunk/wb/account/login.php
62 62
									"MIN_PASSWORD_LEN" => "2",
63 63
									"MAX_USERNAME_LEN" => "30",
64 64
									"MAX_PASSWORD_LEN" => "30",
65
									"LOGIN_URL" => WB_URL."/account/login".PAGE_EXTENSION,
65
									"LOGIN_URL" => WB_URL."/account/login".PAGE_EXTENSION.'?redirect='.$_REQUEST['redirect'],
66 66
									"DEFAULT_URL" => WB_URL.PAGES_DIRECTORY."/index".PAGE_EXTENSION,
67 67
									"TEMPLATE_DIR" => ADMIN_PATH."/login",
68 68
									"TEMPLATE_FILE" => "template.html",
69 69
									"FRONTEND" => true,
70 70
									"FORGOTTEN_DETAILS_APP" => WB_URL."/account/forgot.php".PAGE_EXTENSION,
71 71
									"USERS_TABLE" => TABLE_PREFIX."users",
72
									"GROUPS_TABLE" => TABLE_PREFIX."groups"
72
									"GROUPS_TABLE" => TABLE_PREFIX."groups",
73
									"REDIRECT_URL" => $_REQUEST['redirect']
73 74
							)
74 75
					);
75 76

  
trunk/wb/framework/class.login.php
61 61
		$this->forgotten_details_app = $config_array['FORGOTTEN_DETAILS_APP'];
62 62
		$this->max_username_len = $config_array['MAX_USERNAME_LEN'];
63 63
		$this->max_password_len = $config_array['MAX_PASSWORD_LEN'];
64
		$this->redirect_url = $config_array['REDIRECT_URL'];
64 65
		// Get the supplied username and password
65 66
		if ($this->get_post('username_fieldname') != ''){
66 67
			$username_fieldname = $this->get_post('username_fieldname');
......
84 85
		}
85 86
		// If the url is blank, set it to the default url
86 87
		$this->url = $this->get_post('url');
88
		if ($this->redirect_url!='') {
89
			$this->url = $this->redirect_url;
90
		}		
87 91
		if(strlen($this->url) < 2) {
88 92
			$this->url = $config_array['DEFAULT_URL'];
89 93
		}
90
		// Login the user
91 94
		if($this->is_authenticated() == true) {
92 95
			// User already logged-in, so redirect to default url
93 96
			header('Location: '.$this->url);
......
134 137
			$this->password = md5($this->password);
135 138
			if($this->authenticate()) {
136 139
				// Authentication successful
140
				//echo $this->url;exit();
137 141
				header("Location: ".$this->url);
138 142
			} else {
139 143
				$this->message = $MESSAGE['LOGIN']['AUTHENTICATION_FAILED'];
trunk/wb/framework/class.frontend.php
220 220
			// Check if the user is authenticated
221 221
			if($this->is_authenticated() == false) {
222 222
				// User needs to login first
223
				header("Location: ".WB_URL."/account/login".PAGE_EXTENSION);
223
				header("Location: ".WB_URL."/account/login".PAGE_EXTENSION.'?redirect='.$this->link);
224 224
			}
225 225
			// Check if we should show this page
226 226
			if($this->show_page($this->page) == false) {

Also available in: Unified diff