1
0
mirror of https://github.com/flarum/core.git synced 2025-08-04 23:47:32 +02:00

Finish signup process, including state restoration

This commit is contained in:
Toby Zerner
2015-02-25 15:34:02 +10:30
parent 076be26001
commit 9ea482254c
15 changed files with 62 additions and 29 deletions

View File

@@ -21,7 +21,7 @@ class CoreServiceProvider extends ServiceProvider
*/
public function boot(Dispatcher $events, Bus $bus)
{
$this->loadViewsFrom(__DIR__.'../../views', 'flarum');
$this->loadViewsFrom(__DIR__.'/../../views', 'flarum');
$this->registerEventHandlers($events);
$this->registerPostTypes();

View File

@@ -2,7 +2,7 @@
use Flarum\Core\Models\User;
class EmailWasChanged
class UserEmailWasChanged
{
public $user;

View File

@@ -2,7 +2,7 @@
use Flarum\Core\Models\User;
class EmailWasConfirmed
class UserEmailWasConfirmed
{
public $user;

View File

@@ -2,7 +2,7 @@
use Flarum\Core\Models\User;
class PasswordWasChanged
class UserPasswordWasChanged
{
public $user;

View File

@@ -1,5 +1,7 @@
<?php namespace Flarum\Core\Handlers\Commands;
use Flarum\Core\Models\User;
use Flarum\Core\Events\UserWillBeSaved;
use Flarum\Core\Support\DispatchesEvents;
class RegisterUserCommandHandler

View File

@@ -3,6 +3,7 @@
use Illuminate\Mail\Mailer;
use Flarum\Core\Events\UserWasRegistered;
use Flarum\Core\Events\EmailWasChanged;
use Config;
class EmailConfirmationMailer
{
@@ -29,7 +30,7 @@ class EmailConfirmationMailer
{
$user = $event->user;
$forumTitle = Config::get('flarum::forum_tite');
$forumTitle = Config::get('flarum::forum_title');
$data = [
'username' => $user->username,
@@ -37,8 +38,10 @@ class EmailConfirmationMailer
'url' => route('flarum.confirm', ['id' => $user->id, 'token' => $user->confirmation_token])
];
$this->mailer->send(['text' => 'flarum::emails.confirm'], $data, function ($message) use ($user) {
$message->to($user->email)->subject('['.$forumTitle.'] Email Address Confirmation');
$this->mailer->send(['text' => 'flarum::emails.confirm'], $data, function ($message) use ($user, $forumTitle) {
$message->to($user->email);
$message->subject('['.$forumTitle.'] Email Address Confirmation');
$message->from('noreply@localhost', $forumTitle);
});
}

View File

@@ -6,10 +6,10 @@ use Flarum\Core\Exceptions\InvalidConfirmationTokenException;
use Flarum\Core\Events\UserWasDeleted;
use Flarum\Core\Events\UserWasRegistered;
use Flarum\Core\Events\UserWasRenamed;
use Flarum\Core\Events\EmailWasChanged;
use Flarum\Core\Events\PasswordWasChanged;
use Flarum\Core\Events\UserEmailWasChanged;
use Flarum\Core\Events\UserPasswordWasChanged;
use Flarum\Core\Events\UserWasActivated;
use Flarum\Core\Events\EmailWasConfirmed;
use Flarum\Core\Events\UserEmailWasConfirmed;
class User extends Model
{
@@ -115,7 +115,7 @@ class User extends Model
{
if ($email !== $this->email) {
$this->email = $email;
$this->raise(new EmailWasChanged($this));
$this->raise(new UserEmailWasChanged($this));
}
return $this;
@@ -130,7 +130,7 @@ class User extends Model
public function changePassword($password)
{
$this->password = $password ? static::$hasher->make($password) : null;
$this->raise(new PasswordWasChanged($this));
$this->raise(new UserPasswordWasChanged($this));
return $this;
}
@@ -211,7 +211,7 @@ class User extends Model
$this->is_confirmed = true;
$this->confirmation_token = null;
$this->raise(new EmailWasConfirmed($this));
$this->raise(new UserEmailWasConfirmed($this));
return $this;
}
@@ -302,6 +302,16 @@ class User extends Model
return Permission::whereIn('grantee', $this->getGrantees());
}
/**
* Define the relationship with the user's access tokens.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function accessTokens()
{
return $this->hasMany('Flarum\Core\Models\AccessToken');
}
/**
* Set the hasher with which to hash passwords.
*