Ejemplo n.º 1
0
 function get_reset_password($email, $hash)
 {
     $days = \Vane\Current::config('general.password.reset_days');
     try {
         $email = $this->decodeValue($email);
         $user = User::where('email', '=', $email)->first();
         if (!$user) {
             throw new Error('User not found');
         }
         $valid = false;
         for ($day = 0; $day <= $days; $day++) {
             if ($user->resetHash($day, $hash)) {
                 $valid = true;
                 break;
             }
         }
         if (!$valid) {
             throw new Error('Hash is invalid');
         }
         $newPassword = User::generatePassword();
         $user->password = $newPassword;
         $user->save();
         \Vane\Mail::sendTo($user->emailRecipient(), 'vanemart::mail.user.new_password', array('email' => $email, 'password' => $newPassword));
         $this->status('new_password');
         Auth::login($user->id);
     } catch (\Exception $e) {
         Log::error_User('Error while resetting password: '******'vanemart::login'));
 }
Ejemplo n.º 2
0
            $max = -1;
        } else {
            $max = \Config::get('vanemart::post.add.max_attaching_files', 10);
        }
        $attached = $options['post']->attach('attach', $max, $block->user());
        $models = array_merge($models, $attached);
    }
});
// Fired after successfully adding a post with attachments and all required database
// and other changes.
//
//* $options hash - the same as in post.attach plus 'attachments' hash of File.
Event::listen(VANE_NS . 'post.added', function (array $options) {
    extract($options, EXTR_SKIP);
    $poster = $block->user(false);
    $to = User::all(arrize(\Vane\Current::config('general.post_notify_users')));
    if ($type === 'order' and $order = Order::find($object)) {
        foreach (array('user', 'manager') as $field) {
            $to[] = $order->{$field}()->first();
        }
    }
    foreach ($to as $recipient) {
        if (!$poster or $poster->email != $recipient->email) {
            \Vane\Mail::sendTo($recipient->emailRecipient(), 'vanemart::mail.order.post', array('order' => $order->to_array(), 'user' => $block->user()->to_array(), 'recipient' => $recipient->to_array(), 'post' => $post->to_array(), 'files' => func('to_array', $attachments)));
        }
    }
});
// Fired after post.added if post is attached to an object.
//
//* $object Eloquent
//* $options hash - the same as in post.added.