Skip to content

Commit

Permalink
Apply fixes from StyleCI (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
emredipi authored Nov 22, 2020
1 parent cfc973e commit 15f9f89
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
19 changes: 10 additions & 9 deletions src/config/isAuth.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

return [
"middleware"=>['web'], //for laravel routes (web,api...)
"options"=>[
"loginField"=>"email", //If your project uses username to login, change it with "username".
"texts"=>[ //translate
"placeholder"=>"Type Your Password",
"wrong"=>"Wrong Password",
"error"=>"Error",
"button"=>"Login"
]
'middleware'=> ['web'], //for laravel routes (web,api...)
'options' => [
'loginField'=> 'email', //If your project uses username to login, change it with "username".
'texts' => [ //translate
'placeholder'=> 'Type Your Password',
'wrong' => 'Wrong Password',
'error' => 'Error',
'button' => 'Login',
],
],
];
21 changes: 11 additions & 10 deletions src/isAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@

namespace spiderwebtr\isauth;

use App\Http\Controllers\Auth\LoginController;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class isAuthController extends Controller
{

function isAuth(){
public function isAuth()
{
return response()->json(
["logged"=>\Auth::check(), "csrf"=>(csrf_token())]
['logged'=>\Auth::check(), 'csrf'=>(csrf_token())]
);
}

function ajaxlogin(Request $request){
$success=\Auth::attempt([
$request->loginField=>$request->username,
"password"=>$request->password
public function ajaxlogin(Request $request)
{
$success = \Auth::attempt([
$request->loginField=> $request->username,
'password' => $request->password,
]);
return $success?$this->isAuth():"{logged:false}";

return $success ? $this->isAuth() : '{logged:false}';
}
}
2 changes: 1 addition & 1 deletion src/isAuthServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

namespace spiderwebtr\isauth;

use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;

Expand Down Expand Up @@ -32,5 +33,4 @@ public function boot()
public function register()
{
}

}
7 changes: 4 additions & 3 deletions src/routes/routes.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
Route::middleware(config('isAuth.middleware')??'web')->namespace("spiderwebtr\isauth")->group(function (){
Route::get("isAuth","isAuthController@isAuth")->name("isAuth");
Route::post("ajaxlogin","isAuthController@ajaxlogin");

Route::middleware(config('isAuth.middleware') ?? 'web')->namespace("spiderwebtr\isauth")->group(function () {
Route::get('isAuth', 'isAuthController@isAuth')->name('isAuth');
Route::post('ajaxlogin', 'isAuthController@ajaxlogin');
});

0 comments on commit 15f9f89

Please sign in to comment.