Beispiel #1
0
 public static function registerUser($input)
 {
     $User = new User();
     $id = $User->insert_get_id(array('username' => $input['username'], 'password' => Hash::make($input['password']), 'validationkey' => $input['key'], 'created_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s"), 'status' => 3, 'role' => $input['role']));
     unset($input['username']);
     unset($input['password']);
     unset($input['role']);
     unset($input['key']);
     if ($id) {
         // $extension = File::extension($input['imgpath']['name']);
         // $directory = path('public').'avatar/'.sha1($id);
         // $filename = sha1($id.time()).".{$extension}";
         // if($input['imgpath']['size'] != null){
         //     $upload_success = Input::upload('photo', $directory, $filename);
         //     if( $upload_success ) {
         //         $input['imgpath'] = 'avatar/'.sha1($id).'/'.$filename;
         //     }else{
         //         $input['imgpath'] = '';
         //     }
         // }else{
         //     $input['imgpath'] = '';
         // }
         $profile = new Profile(array('fullname' => $input['fullname'], 'icno' => $input['icno'], 'created_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s"), 'emel' => $input['emel']));
         $user = User::find($id);
         $user->userprofile()->insert($profile);
         Log::write('User', 'User ' . $input['icno'] . ' registered');
         return $profile->exists;
     } else {
         Log::write('User', 'User ' . $input['icno'] . ' failed registered');
         return false;
     }
 }
 /**
  * Little helper function to add a new client to the database.
  *
  * @param $client_id     Client identifier to be stored.
  * @param $client_secret Client secret to be stored.
  * @param $redirect_uri  Redirect URI to be stored.
  */
 public function addClient($client_id, $client_secret, $redirect_uri)
 {
     try {
         $client_secret = \Laravel\Hash::make($client_secret . $client_id);
         $client = new \OAuth2Server\Models\Client();
         $client->client_id = $client_id;
         $client->client_secret = $client_secret;
         $client->redirect_uri = $redirect_uri;
         $client->save();
     } catch (Exception $e) {
         $this->handleException($e);
     }
 }