/** * Attempt to authenticate a user using the given credentials. * * @param array $credentials * * @return array */ public static function attempt(array $credentials) { $api = Api::get()->addSession($credentials['user'], $credentials['password']); $payload = \JWTFactory::make(['id' => $api->getSession()]); $token = \JWTAuth::encode($payload); return $token->get(); }
/** * Select Fields Array * * @return array */ private function selectFields() { $data = Api::get()->getModuleFields($this->module); return array_filter($data['module_fields'], function ($key) { return in_array($key, $this->fields); }, ARRAY_FILTER_USE_KEY); }
/** * Create New Records. * * @param $module * @param array $data * * @return bool */ public static function create($module, array $data) { $data = Api::get()->setEntries($module, $data); if (array_key_exists('ids', $data)) { return true; } return false; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { $token = GenerateToken::getToken(); if (!is_null($token)) { Api::get()->setSession($token['id']); return $next($request); } abort(401, "permission denied"); }