flarum / framework

Simple forum software for building great communities.
http://flarum.org/
6.35k stars 834 forks source link

laravel 5 passport and vuejs 2 #1571

Closed hamzadjebiri closed 6 years ago

hamzadjebiri commented 6 years ago

Hey, I installed passport on my Laravel 5.5 + vuejs2 project .. know im confusing about how can i use it in MyPage.vue i already protect the route in api with middleware('auth') now i get 401 (Unauthorized) i cant find any good tutorial for this !

Here My page.vue

         AddQuestion( NewQuestion ){

          this.$http.post('/api/AddQuestion',{

                    // api_token:this.usertoken ,

                    Title_Forum : NewQuestion[0] ,  

                    Text_Forum : NewQuestion[1] ,  

              }).then(response => {

                          this.questions = response.data ;

                    }).catch( (error) =>{   console.log(error) }

              );

         } ,

and this is the api route

Route::middleware('auth')->group(function () { Route::post('/AddQuestion','ForumController@AddQuestion') });

this is my controller

     public function AddQuestion(Request $request){

           $newQuestion = new Forum() ;

           $newQuestion->Title_Forum = $request->input('Title_Forum');

           $newQuestion->Text_Forum =  $request->input('Text_Forum') ;

           $newQuestion->Statu_Forum = "test" ;

           $newQuestion->BestComment_Forum = 1 ;

           $newQuestion->save();

           $getQuestions = Forum::orderBy('created_at','desc')->paginate(10);

           return response()->json($getQuestions) ;

    }

help please !

luceos commented 6 years ago

Hi and thank you for calling in for support. However this project is about flarum a forum tool built using Mithril and Laravel components. There's no relation with Vue and no direct relation with Laravel.

Please find help on the Laracasts forum, Stackoverflow or in the many other Laravel related community resources like Larachat, the official Laravel Discord etc

Good luck, vue and laravel are awesome!