/**
  * @api {get} /activate Active User
  * @apiName GetUser
  * @apiGroup User
  *
  * @apiParam {String} sourse encrypt string.
  *
  * @apiError 400 Link Invalid. This will happen if param is not sent out.
  * @apiError 404 Not found. This will happen if the role id/user id/group id is not in our system.
  * @apiError 409 Link already activated.
  * @apiError 409 Link Expired. 24h.
  */
 public static function setActive()
 {
     $app = \Slim\Slim::getInstance();
     $data = $app->request->get();
     if (!isset($data['source'])) {
         $app->halt('400', json_encode("Link is invalid."));
     }
     $idUser = openssl_decrypt($data['source'], 'AES-256-CBC', self::$pass, 0, self::$iv);
     $user = User::find($idUser);
     if (!$user) {
         $app->halt('404', json_encode("Link is invalid. Please Sign Up."));
     }
     if ($user->active) {
         $app->halt('409', json_encode("Link is invalid. You already activated your acount."));
     }
     $created_at = new DateTime($user->created_at);
     $interval = date_create('now')->diff($created_at);
     if ($interval->d >= 1) {
         $app->halt('408', json_encode("Link expired."));
     }
     $user->active = 1;
     $saved = $user->save();
     if ($saved) {
         GroupController::activeEnroll($idUser);
         EmailController::newUserWelcome($idUser);
         return json_encode("success");
     } else {
         $app->halt('500', json_encode("update to db error"));
     }
 }