All Projects → spatie → Laravel Welcome Notification

spatie / Laravel Welcome Notification

Licence: mit
Send a welcome notification to new users

Projects that are alternatives of or similar to Laravel Welcome Notification

Laravel Mail Preview
A mail driver to quickly preview mail
Stars: ✭ 851 (+184.62%)
Mutual labels:  laravel, mail
Laravel Mail Editor
MailEclipse ⚡ Laravel Mailable Editor!
Stars: ✭ 1,714 (+473.24%)
Mutual labels:  laravel, mail
Laravel5.7 Vue Cli3 Boilerplate
Boilerplate / Starter kit. Laravel 5.7, Vue CLI 3 — Authentication with Email Verification. REST API.
Stars: ✭ 52 (-82.61%)
Mutual labels:  laravel, auth
Laravel Url Signer
Create and validate signed URLs with a limited lifetime
Stars: ✭ 611 (+104.35%)
Mutual labels:  laravel, mail
Laravel Adminless Ldap Auth
Authenticate users in Laravel against an adminless LDAP server
Stars: ✭ 199 (-33.44%)
Mutual labels:  laravel, auth
Laravel Mailbox
Catch incoming emails in your Laravel application
Stars: ✭ 783 (+161.87%)
Mutual labels:  laravel, mail
Sentinel
A framework agnostic authentication & authorization system.
Stars: ✭ 1,354 (+352.84%)
Mutual labels:  laravel, auth
Go Msgauth
A Go library for DKIM, DMARC and Authentication-Results
Stars: ✭ 63 (-78.93%)
Mutual labels:  mail, auth
Laravel Auth Checker
Laravel Auth Checker allows you to log users authentication, devices authenticated from and lock intrusions.
Stars: ✭ 177 (-40.8%)
Mutual labels:  laravel, auth
Laravel Disposable Email
Disposable email address validator for Laravel
Stars: ✭ 147 (-50.84%)
Mutual labels:  laravel, mail
Shinobi
👺 Simple and light-weight role-based permissions system for Laravel's built in Auth system.
Stars: ✭ 349 (+16.72%)
Mutual labels:  laravel, auth
IMAPLoginTester
A simple Python script that reads a text file with lots of e-mails and passwords, and tries to check if those credentials are valid by trying to login on IMAP servers.
Stars: ✭ 47 (-84.28%)
Mutual labels:  mail, password
Jwt Auth Guard
JWT Auth Guard for Laravel and Lumen Frameworks.
Stars: ✭ 319 (+6.69%)
Mutual labels:  laravel, auth
Adldap2 Laravel
LDAP Authentication & Management for Laravel
Stars: ✭ 825 (+175.92%)
Mutual labels:  laravel, auth
Laravel Mail Viewer
View all the mailables in your laravel app at a single place
Stars: ✭ 315 (+5.35%)
Mutual labels:  laravel, mail
Brandenburg
Laravel Authentication Package
Stars: ✭ 79 (-73.58%)
Mutual labels:  laravel, auth
Huge
Simple user-authentication solution, embedded into a small framework.
Stars: ✭ 2,125 (+610.7%)
Mutual labels:  password, auth
Laravel Mailable Test
An artisan command to easily test mailables
Stars: ✭ 143 (-52.17%)
Mutual labels:  laravel, mail
Bouncer
Eloquent roles and abilities.
Stars: ✭ 2,763 (+824.08%)
Mutual labels:  laravel, auth
Mailgun
Mailgun package for Laravel
Stars: ✭ 297 (-0.67%)
Mutual labels:  laravel, mail

Send a welcome notification to new users

Latest Version on Packagist GitHub Workflow Status Total Downloads

Using this package you can send a WelcomeNotification to a new user of your app. The notification contains a secure link to a screen where the user can set an initial password.

$expiresAt = now()->addDay();

$user->sendWelcomeNotification($expiresAt);

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require spatie/laravel-welcome-notification

Migrating the database

You must publish the migrations provided by this package by executing this command:

php artisan vendor:publish --provider="Spatie\WelcomeNotification\WelcomeNotificationServiceProvider" --tag="migrations"

Next, you must migrate your database.

php artisan migrate

Preparing the user model

You must apply the \Spatie\WelcomeNotification\ReceivesWelcomeNotification trait to your User model.

Preparing the WelcomeController

Next you'll need to create a controller of your own that will extend Spatie\WelcomeNotification\WelcomeController. This controller will be used to show the welcome form and to save the password set by a user.

namespace App\Http\Controllers\Auth;

use Spatie\WelcomeNotification\WelcomeController as BaseWelcomeController;

class MyWelcomeController extends BaseWelcomeController
{
}

Registering the routes

You'll have to register these routes:

use Spatie\WelcomeNotification\WelcomesNewUsers;
use App\Http\Controllers\Auth\MyWelcomeController;

Route::group(['middleware' => ['web', WelcomesNewUsers::class,]], function () {
    Route::get('welcome/{user}', [MyWelcomeController::class, 'showWelcomeForm'])->name('welcome');
    Route::post('welcome/{user}', [MyWelcomeController::class, 'savePassword']);
});

Preparing the welcome form view

The welcome view that ships with the package, will be rendered when somebody clicks the welcome link in the welcome notification mail. You should style this view yourself. You can publish the views with this command:

php artisan vendor:publish --provider="Spatie\WelcomeNotification\WelcomeNotificationServiceProvider" --tag="views"

Usage

Here's how you can send a welcome notification to a user that you just created.

$expiresAt = now()->addDay();

$user->sendWelcomeNotification($expiresAt);

Handling successful requests

After the a user has successfully set a new password the sendPasswordSavedResponse of the WelcomeController will get called.

use Symfony\Component\HttpFoundation\Response;

class MyWelcomeController extends BaseWelcomeController
{
    public function sendPasswordSavedResponse(): Response

    {
        return redirect()->route('home');
    }
}

Customizing the notification

By default the WelcomeNotification will send a mail. If you wish to customize the mail you can extend WelcomeNotification and override the buildWelcomeNotificationMessage method.

use Illuminate\Notifications\Messages\MailMessage;

class MyCustomWelcomeNotification extends WelcomeNotification
{
    public function buildWelcomeNotificationMessage(): MailMessage
    {
        return (new MailMessage)
            ->subject('Welcome to my app')
            ->action(Lang::get('Set initial password'), $this->showWelcomeFormUrl)
    }
}

To use the custom notification you must add a method called sendWelcomeNotification to your User model.

public function sendWelcomeNotification(\Carbon\Carbon $validUntil)
{
    $this->notify(new MyCustomWelcomeNotification($validUntil));
}

Validating extra fields

The default welcome form that ships with this package only asks for a password. You can add more fields to the form by publishing the view and adding more fields to it.

To validate new fields you can override the rules function in your own WelcomeController. Here's an example where we want to validate an extra field named job_title.

class MyWelcomeController extends BaseWelcomeController
{
    public function rules()
    {
        return [
            'password' => 'required|confirmed|min:6',
            'job_title' => 'required',
        ];
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].