Commit e184db48 authored by Frank Bergmann's avatar Frank Bergmann

- added auto-login - got somehow lost before

- fixed registration when upgrading a party to a user
parent 7bc78640
......@@ -1676,6 +1676,9 @@ ad_proc -public im_generate_auto_login {
} {
Generates a security token for auto_login
} {
set user_password ""
set user_salt ""
set user_data_sql "
select
u.password as user_password,
......@@ -1684,7 +1687,7 @@ ad_proc -public im_generate_auto_login {
users u
where
u.user_id = :user_id"
db_1row get_user_data $user_data_sql
db_0or1row get_user_data $user_data_sql
# generate the expected auto_login variable
return [ns_sha1 "$user_id$user_password$user_salt$expiry_date"]
......
# /packages/intranet-core/www/auto_login.tcl
#
# Copyright (C) 2005 ]project-open[
#
# This program is free software. You can redistribute it
# and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation;
# either version 2 of the License, or (at your option)
# any later version. This program is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
ad_page_contract {
Purpose: login & redirect a user, based on a "auto_login"
field that contains the information about the user's password
in a sha1 HASH.
Example use:
http://projop.dnsalias.com/intranet/auto_login?user_id=1234&url=/intranet-forum/&auto_login=E4E412EE1ACA294D4B9AC51B108360EEF7B307C1
@@param user_id Login as this user
@@param url What page to go to
@@param token A hashed combination of user_id, passwd & salt
@@author frank.bergmann@@project-open.com
} {
user_id:integer
{ url "/intranet/" }
{ auto_login "" }
}
set valid_login [im_valid_auto_login_p -user_id $user_id -auto_login $auto_login]
if {$valid_login} {
ad_user_login -forever=0 $user_id
ad_returnredirect $url
} else {
ad_return_complaint 1 "<b>Wrong Security Token</b>:<br>
Your security token is not valid. Please contact the system owner.<br>
"
}
......@@ -315,6 +315,12 @@ ad_form -extend -name register -on_request {
:user_id, :first_names, :last_name
)
"
# Convert the party into a person
db_dml person2party "
update acs_objects
set object_type = 'person'
where object_id = :user_id
"
}
set user_exists_p [db_string user_exists "select count(*) from users where user_id = :user_id"]
......@@ -327,6 +333,22 @@ ad_form -extend -name register -on_request {
:user_id, :username
)
"
# Convert the person into a user
db_dml party2user "
update acs_objects
set object_type = 'user'
where object_id = :user_id
"
# Add the user to the "Registered Users" group, because
# (s)he would get strange problems otherwise
set registered_users [db_string registered_users "select object_id from acs_magic_objects where name='registered_users'"]
relation_add -member_state "approved" "membership_rel" $registered_users $user_id
# Add a users_contact record to the user since the 3.0 PostgreSQL
# port, because we have dropped the outer join with it...
catch { db_dml add_users_contact "insert into users_contact (user_id) values (:user_id)" } errmsg
catch { db_dml add_user_preferences "insert into user_preferences (user_id) values (:user_id)" } errmsg
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment