koole / react-sanctum

Easily hook up your React app to Laravel Sanctum and Laravel Fortify
MIT License
152 stars 26 forks source link

Redirect if not authenticated #218

Closed ezequiel9 closed 1 year ago

ezequiel9 commented 1 year ago

Hi, I am enjoying this package, works perfect so far. Thank you.

Just come here to ask you if you have a best way to redirect to another page if the user is not authenticated. For example lets say "dashboard" it should redirect if not logged in.

This is my page

import React, { Component } from 'react'

import { Default } from '@/components/templates/Default'

class Dashboard extends Component {

    render() {
        return (
            <>
                <Default description="Dashboard Description" title="User's Dashboard">
                    <div className="user-area-all-style sign-up-area pt-100 bg-black">
                        Dashboard Content
                    </div>
                </Default>
            </>
        )
    }
}

export default Dashboard
koole commented 1 year ago

This was answered before in #13, hopefully that will answer your question.

ezequiel9 commented 1 year ago

Great, Thanks!