Ejemplo n.º 1
0
function dldc_login($username, $password)
{
    if ($user = DLDC_User::login($username, $password)) {
        $_SESSION['DLDC_USER'] = $user;
        $_SESSION['DLDC_IS_ADMIN'] = dldc_is_admin();
        return true;
    } else {
        return false;
    }
}
Ejemplo n.º 2
0
function dldc_update_profile(DLDC_User $user, $password)
{
    $data = array('email' => trim(Common::getPostString('email')), 'firstname' => trim(Common::getPostString('firstname')), 'lastname' => trim(Common::getPostString('lastname')));
    if (!empty($password)) {
        if (!DLDC_User::login(dldc_username(), Common::getPostString('password_old'))) {
            return dldc_error('You have to supply your current password to change it.');
        }
        if ($password !== Common::getPostString('password_retype')) {
            return dldc_error('You have to retype your new password correctly.');
        }
        $data['password'] = DLDC_User::hashPassword($password);
        dldc_message('Your password has been changed!');
    }
    $user->saveVars($data);
    dldc_message('Information has been saved.');
}