00001 <?php
00002
00003
00004
00005
00006
00007
00008 class OnetimeloginConfirmationHandler extends ConfirmationHandlerBase {
00009
00010
00011
00012
00013
00014
00015
00016
00017 protected function do_confirm($confirmation, $success) {
00018 if ($success == self::SUCCESS) {
00019 $user = Users::get($confirmation->id_item);
00020 if ($user && $user->is_active()) {
00021 Users::confirm_email($user);
00022 if (Users::do_login($user)) {
00023 $msg = new Message(tr('You have been automatically logged in. You now can change your password.', 'users'));
00024 $msg->persist();
00025 $redirect = ActionMapper::get_url('edit_self', $user);
00026 Url::create($redirect)->redirect();
00027 exit;
00028 }
00029 else {
00030 return new Status(tr('Automatically login in failed', 'users'));
00031 }
00032 }
00033 else {
00034 return new Status(tr('No matching user account was found', 'users'));
00035 }
00036 }
00037 else {
00038 return parent::do_confirm($confirmation, $success);
00039 }
00040 }
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 protected function do_created($confirmation) {
00051 $ret = new Status();
00052
00053 $user = Users::get($confirmation->id_item);
00054 if ($user) {
00055 Load::commands('generics/mail');
00056 $cmd = new MailCommand(
00057 tr('One time login', 'users'),
00058 $user->email,
00059 'users/mail/onetimelogin',
00060 array('confirmation' => $confirmation)
00061 );
00062 $ret->merge($cmd->execute());
00063 }
00064 else {
00065 $ret->append(tr('Unkown User set on one time login confirmation', 'users'));
00066 }
00067
00068 return $ret;
00069 }
00070
00071 }