-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xnetevents non x subscription #26
base: master
Are you sure you want to change the base?
Changes from 1 commit
8786f80
8b97f15
e0e2a7e
f7fec11
4fd14b6
6fc7a66
422fe0d
16c1676
af8b5c6
66632e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -244,10 +244,33 @@ function handler_sub($page, $eid = null) | |
|
||
//if we arrived here via a confirmation email, process it | ||
if(Get::has('nom') && Get::has('prenom') && Get::has('email') && Get::has('token')){ | ||
if(Get::v('token')!=make_confirmation_token($nom,$prenom,$email)){ | ||
if(Get::v('token')!=$this->make_confirmation_token(Get::v('nom'),Get::v('prenom'),Get::v('email'))){ | ||
$page->kill('Ce lien n\'est pas valide.'); | ||
} | ||
XDB::execute('INSERT INTO accounts SET firstname={?}, lastname={?}, hruid={?}, email={?}', Get::v('prenom'), Get::v('nom'), Get::v('prenom').".".Get::v('nom'), Get::v('email')); | ||
|
||
//check if the email address is already registered | ||
$res=XDB::query("SELECT hruid FROM accounts WHERE email={?}", Get::v('email')); | ||
|
||
if($res->numRows()>0){ | ||
//the email address is already registered, use the registered account | ||
$hruid=(string)$res->fetchOneCell(); | ||
}else{ | ||
//the email address is not registered, create a new user | ||
require_once 'name.func.inc.php'; | ||
list($local_part, $domain) = explode('@', strtolower(Get::v('email'))); | ||
$firstname=Get::v('prenom'); | ||
$lastname=Get::v('nom'); | ||
$hruid = User::makeHrid($local_part, $domain, 'ext'); | ||
$full_name = build_full_name($firstname, $lastname); | ||
$directory_name = build_directory_name($firstname, $lastname); | ||
$sort_name = build_sort_name($firstname, $lastname); | ||
XDB::execute('INSERT INTO accounts SET firstname={?}, lastname={?}, full_name={?}, directory_name={?}, sort_name={?}, hruid={?}, email={?}, type={?}, state={?}', $firstname, $lastname, $full_name, $directory_name, $sort_name, $hruid, Get::v('email'), "xnet", "active"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may break if an hruid already exists for the given email address?
A possible solution would be to add a counter when a collision happens |
||
} | ||
$user=User::get($hruid); | ||
var_dump($user); | ||
if(!Platal::session()->logAsUser($user)){ | ||
$page->kill("Authentication failed for $hruid."); | ||
} | ||
} | ||
|
||
if (S::logged()) { | ||
|
@@ -360,7 +383,7 @@ function handler_sub($page, $eid = null) | |
$nom=Post::v('nom'); | ||
$prenom=Post::v('prenom'); | ||
$email=Post::v('email'); | ||
$token=make_confirmation_token($nom,$prenom,$email); | ||
$token=$this->make_confirmation_token($nom,$prenom,$email); | ||
$base = $globals->baseurl . '/' . $platal->ns . $globals->asso('diminutif'); | ||
$url = "$base/events/sub/$eid?nom=".urlencode($nom)."&prenom=".urlencode($prenom)."&email=".urlencode($email)."&token=$token"; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to check the email redirections too