Skip to content

Instantly share code, notes, and snippets.

@ChrisFrench
Created December 10, 2014 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisFrench/3272d507f65410a43118 to your computer and use it in GitHub Desktop.
Save ChrisFrench/3272d507f65410a43118 to your computer and use it in GitHub Desktop.
<?php
namespace Api\Site\Controllers;
class Auth extends Base {
public function beforeroute() {
$array = $this->input->getArray ();
if (empty ( $array ['key'] )) {
\Dsc\Mongo\Collections\Logs::add('KEY WAS EMPTY');
$this->apiError ('Key is required' );
} else {
$key = $array ['key'];
//\Dsc\Mongo\Collections\Logs::add($key);
}
$actor = (new \Rystband\Models\Users ())->setState ( 'filter.auto_login_token', $key )->getItem ();
if (empty ( $actor->id )) {
$this->apiError( 'Invalid Key, login again to refresh your key');
\Dsc\Mongo\Collections\Logs::add('Invalid Key, login again to refresh your key');
} else {
$this->app->set ( 'user', $actor );
return;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment