Skip to content

Commit df384dd

Browse files
committed
Add confirmed method, called on confirmation.
1 parent fac09fc commit df384dd

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ This package comes with a language file, that allows you to modify the error / c
7474
might see. In addition to that, you can change the notification class that will be used to send the confirmation code
7575
completely, by changing it in the `config/confirmation.php` file.
7676

77+
### Automatically logging users in, or adding custom logic, on confirmation
78+
On successful email confirmation, this package calls a `confirmed` function, which you can override in order to add any custom logic, such as sending a welcome email or automatically logging the user in.
79+
80+
For example, if you want to automatically log the user in on confirmation, inside your `RegisterController` simply add:
81+
```php
82+
public function confirmed($user) {
83+
$this->guard()->login($user);
84+
}
85+
```
86+
7787
### Testing
7888

7989
``` bash

src/Traits/RegistersUsers.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public function confirm($confirmation_code)
2727
$user->confirmed_at = now();
2828
$user->save();
2929

30-
return redirect(route('login'))->with('confirmation', __('confirmation::confirmation.confirmation_successful'));
30+
return $this->confirmed($user)
31+
?: redirect(route('login'))->with('confirmation', __('confirmation::confirmation.confirmation_successful'));
3132
}
3233

3334
/**
@@ -79,4 +80,15 @@ protected function sendConfirmationToUser($user)
7980
$notification = app(config('confirmation.notification'));
8081
$user->notify($notification);
8182
}
83+
84+
85+
/**
86+
* The users email address has been confirmed.
87+
*
88+
* @param mixed $user
89+
* @return mixed
90+
*/
91+
protected function confirmed($user) {
92+
//
93+
}
8294
}

0 commit comments

Comments
 (0)