frumentius

frumentius

Member Since 2 Years Ago

Experience Points
910
Total
Experience

4,090 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
1
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
910 XP
Sep
25
1 month ago
Activity icon

Started a new Conversation From Where The 'verify()' And 'resend()' Function Get It's User Instance?

I'm in the middle of learning this code:

/vendor/laravel/ui/auth-backend/VerifiesEmails.php

public function verify(Request $request)
    {
        if (! hash_equals((string) $request->route('id'), (string) $request->user()->getKey())) {
            throw new AuthorizationException;
        }

        if (! hash_equals((string) $request->route('hash'), sha1($request->user()->getEmailForVerification()))) {
            throw new AuthorizationException;
        }

        if ($request->user()->hasVerifiedEmail()) {
            return $request->wantsJson()
                        ? new Response('', 204)
                        : redirect($this->redirectPath());
        }

        if ($request->user()->markEmailAsVerified()) {
            event(new Verified($request->user()));
        }

        if ($response = $this->verified($request)) {
            return $response;
        }

        return $request->wantsJson()
                    ? new Response('', 204)
                    : redirect($this->redirectPath())->with('verified', true);
    }

I believe this function will be triggered when user click on the verification link. (Example: https://my-domain.com/email/verify/7/819cb7ec10a2da5171b41362204d36c3cac685ef?expires=1601038607&signature=acf5e2b728372bab2717e9d642dc2d80060e0f4fff3db3a89e59ed9807aa0e8f)

What confuse me is, form where this function's $request get the user() instance?

I Suppose it gets it from the middleware->('auth') in constructor, but it confuses me more, that link does not provide password, how come just a link like above could pass authentication??

(same case for the resend() function)

Activity icon

Replied to Customizing The Laravel Verify Email

{
"If you’re having trouble clicking the \":actionText\" button, copy and paste the URL below\ninto your web browser:": "Ef þú ert í vandræðum með að smella á hnappinn \":actionText\", afritaðu og límdu slóðina hér að neðan\ní vafra þinn:"
}

That! would be the right format. No need to add [:actionURL](:actionURL) at the end.

Sep
23
1 month ago
Activity icon

Replied to Laravel Auth Ui Verify Email And Password Reset With React JS Front End Application

Hi thank you for replying, but i think it is not possible to use inertia, because that means restructuring, and rebuilding all my app. I mean i almost finish with this app except those two functionality email verification and forgot password.

Activity icon

Started a new Conversation Laravel Auth Ui Verify Email And Password Reset With React JS Front End Application

I'm building a React JS app with laravel 7.x as back end. I'm using sanctum and laravel ui for authentication. All the login and registering are working well.

But

I've been trying to implement laravel ui built-in verify email and password reset functionality but can't seems to make it works.

My questions is: is it possible to use those two functionality of laravel with React JS application??

Because all the tutorial I've found so far is using only laravel as back end and front end. if it's possible please guide me how..

Activity icon

Replied to Get Client IP Address In Create Function RegisterController Laravel 7.x

@sinnbeck @automica thank you for Your reply.

I've solved this matter by duplicating the register function from laravel vendor into my RegisterController, and then modify it a bit by sending the $request to the create function, not the default array $request->all(). So that I can access $request->ip() in the create function.

Activity icon

Started a new Conversation Get Client IP Address In Create Function RegisterController Laravel 7.x

Hi all, Can anyone help me how to get client IP address in create function in RegisterController? I follow this (https://laracasts.com/discuss/channels/requests/how-to-get-client-ip-address-in-register-controller) discussion but it seems obsolete because this based on laravel 5.3.

So, please can anyone enlighten me for laravel 7.x

Sep
09
1 month ago
Activity icon

Started a new Conversation Laravel Sanctum And Laravel UI Auth Redirection

Grettings Friends,

First of all pardon me, because actually I've got 3 questions, but I don't know the right title to write. So I'm building an SPA, and using laravel 7 as the back end, with sanctum as my method for signing in user. I'm following this tutorial https://laravel-news.com/using-sanctum-to-authenticate-a-react-spa

All is well and I've got it all running normally. But i got 3 additional questions, which are;

  1. Redirection problem, so if I already logged in, and try to login again (I know my app flow should not allow this, but just bear with me) the response will be 204 for /csrf-token, 302 for /login, and then there is additional redirection to /home which resulted in error, i think this behaviour is not suitable for SPA. I've tried remove this line "protected $redirectTo = RouteServiceProvider::HOME;" from the LoginController.php but the problem still persist. So how to disable redirection to /home if already logged in?
  2. In that tutorial the loggedIn state is saved in browser Session Storage, the problem is when I close the tab or the browser, the Session Storage will be cleared causing my login state is false and the app will see me as logged out, while actually the token still see me as logged in. So what is the best practice to save the login state, is moving it from session storage to locale storage is enough, I mean is it secure to just save it in local storage? Or do i need to check to back-end every time i visit pages that needed the user to be logged in, not store the state locally? What is the best practice here?
  3. If I want to add google recaptcha v2 in my login form, where in the back end laravel should i put my code to validate catpcha to google?

Cheers!

Activity icon

Awarded Best Reply on Laravel Sanctum (with Reactjs Spa)

@sinnbeck Yup just trying to use less libraries as possible, and I think that's is the problem in this case, because axios automatically add "X-XSRF-TOKEN" to POST request header, and in fetch we must do it manually, which I don't.

adding this into login fetch seems solving the problem:

headers: {
        "Accept": "application/json",
        "X-XSRF-TOKEN": getCookie("XSRF-TOKEN")
}
Aug
13
2 months ago
Activity icon

Replied to Laravel Sanctum (with Reactjs Spa)

@sinnbeck Yup just trying to use less libraries as possible, and I think that's is the problem in this case, because axios automatically add "X-XSRF-TOKEN" to POST request header, and in fetch we must do it manually, which I don't.

adding this into login fetch seems solving the problem:

headers: {
        "Accept": "application/json",
        "X-XSRF-TOKEN": getCookie("XSRF-TOKEN")
}
Activity icon

Started a new Conversation Laravel Sanctum (with Reactjs Spa)

Greetings guys and gals!

Im in the middle of learning laravel sanctum, Im following this tutorial https://laravel-news.com/using-sanctum-to-authenticate-a-react-spa

Im stuck at the "CSRF" section, after changing the cors.php config value of 'supports_credentials' into true. Im successfully getting both the cookies and a 204 response when connecting to '/sanctum/csrf-cookie'. But after that when trying to connect to '/login', Im getting error 419 unknown status.

Below is my react app code for the login page:

import React from 'react';

const Login = (props) => {
    const [email, setEmail] = React.useState('');
    const [password, setPassword] = React.useState('');
    const handleSubmit = (evt) => {
        evt.preventDefault();

        let postFormData = new URLSearchParams();
        postFormData.append("email", email);
        postFormData.append("password", password);

        fetch("https://api.sanctum-test.com/sanctum/csrf-cookie", {
            method: 'GET',
            mode: 'cors',
            credentials: 'include'
        })
            .then(getSanctumResponse => {
                console.log("Sanctum", getSanctumResponse.status);
                fetch("https://api.sanctum-test.com/login", {
                    method: 'POST',
                    mode: 'cors',
                    credentials: 'include',
                    body: postFormData
                })
                    .then(getResponse => {
                        /* getResponse.json().then(getResponseData => {
                            //
                        }); */
                        console.log("Login", getResponse.status);
                    })
                    .catch(err => {
                        console.log(err);
                    });
            })
            .catch(sanctumErr => {
                console.log(sanctumErr);
            });

        evt.stopPropagation();
        return false;
    }
    return (
        <div>
            <h1>Login</h1>
            <form onSubmit={handleSubmit}>
                <input
                    type="email"
                    name="email"
                    placeholder="Email"
                    value={email}
                    onChange={e => setEmail(e.target.value)}
                    required
                />
                <input
                    type="password"
                    name="password"
                    placeholder="Password"
                    value={password}
                    onChange={e => setPassword(e.target.value)}
                    required
                />
                <button type="submit">Login</button>
            </form>
        </div>
    );
}

export default Login;

Can anyone please help why Im getting this 419 unknown status error..