Ejemplo n.º 1
0
 /**
  * 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();
 }
Ejemplo n.º 2
0
 /**
  * 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);
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }
Ejemplo n.º 4
0
 /**
  * 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");
 }