Beispiel #1
0
<?php 
require HTMLView::pathForTemplate('layout.head');
?>

<body>
	<div class="container">
		<h1>Choose Plan</h1>
		<?php 
if (!empty($plans) && is_array($plans)) {
    echo '<form method="post">';
    CSRFPRotection::generateHTMLTag();
    echo '<table style="width: 100%; text-align: center;"><tr><th>Name</th><th>Cycle / Interval</th><th>Amount</th><th>Actions</th></tr>';
    foreach ($plans as $plan) {
        // Create Row HTML
        printf('<tr><td>%s</td><td>%d %s</td><td>%s %s</td><td><input type="radio" name="plan" value="%s"></td></tr>', $plan['name'], $plan['interval_count'], $plan['interval'], number_format($plan['amount'] / 100, 2), strtoupper($plan['currency']), $plan['id']);
    }
    echo '</table>';
    echo '<p><label>Coupon:</label> <input type="text" style="width: 150px" name="coupon"></p>';
    echo '<p style="text-align: right;"><button type="submit">Select</button></p>';
    echo '</form>';
}
?>
		<p><a href="<?php 
echo RouteController::fqURL('index');
?>
">back to home</a></p>
	</div>
</body>

</html>
Beispiel #2
0
<?php 
require HTMLView::pathForTemplate('layout.head');
?>

<body>
	<div class="container">
		<h1>Register</h1>
		<form method="post" style="text-align: center;">
			<?php 
if (isset($alert)) {
    $alert->renderHTML();
}
?>
			<?php 
CSRFPRotection::generateHTMLTag();
?>
			<p><input type="text" name="email" placeholder="Email Address" value="<?php 
postVar('email');
?>
"></p>
			<p><input type="password" name="password" placeholder="Password"></p>
			<p><button type="submit">Submit</button></p>
		</form>
		<p><a href="<?php 
echo RouteController::fqURL('user.login');
?>
">Login</a></p>
	</div>
</body>

</html>
Beispiel #3
0
 public static function requestUserLogin($redirect)
 {
     self::redirect(RouteController::fqURL('user.login'), array("redirect" => $redirect));
 }
Beispiel #4
0
<body>
	<div class="container">
		<h1>Login</h1>
		<form method="post" style="text-align: center;">
			<?php 
if (isset($alert)) {
    $alert->renderHTML();
}
?>
			<?php 
CSRFPRotection::generateHTMLTag();
?>
			<p><input type="text" name="email" placeholder="Email Address" value="<?php 
postVar('email');
?>
"></p>
			<p><input type="password" name="password" placeholder="Password"></p>
			<p><button type="submit">Submit</button></p>
		</form>
		<p><a href="<?php 
echo RouteController::fqURL('user.register');
?>
">Register</a></p>
		<p><a href="<?php 
echo RouteController::fqURL('resetPassword');
?>
">Reset Password</a></p>
	</div>
</body>

</html>
Beispiel #5
0
 public function resetPassword()
 {
     $this->view = new HTMLView();
     if ($this->request->isPOST()) {
         $post = $this->request->postData();
         $user = new UserModel();
         if ($this->request->isQueryArgSet('token')) {
             if ($user->getUserForPasswordResetToken($this->request->queryArgValue('token'))) {
                 $user->password = @$post['password'];
                 if ($user->save()) {
                     $user->deletePasswordResetTokens();
                     $alert = new Alert(Alert::SUCCESS);
                     $alert->addMessage('Password Set, Please Login');
                 } else {
                     $alert = new Alert(Alert::ERROR);
                     $alert->addMessageArray($user->getErrors());
                 }
                 $this->view->includeTemplate('auth.reset-password.password', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]);
             } else {
                 AppController::redirect(RouteController::fqURL('resetPassword'), ['status' => 'token-expired']);
             }
         } else {
             if ($post['email'] && $user->find($post['email'], 'email')) {
                 $token = $user->getPasswordResetTokenData();
                 if ($token['last_email_timestamp'] <= Carbon::now()->subMinutes(pow(2, $token['email_attempts']))) {
                     $user->incrementPasswordResetEmailCount();
                     $link = addQueryParams(RouteController::fqURL('resetPassword'), ['token' => $token['token']]);
                     // Send Email
                     $mailer = new Mailer();
                     $mailer->setSubject('Password Reset Token');
                     $mailer->addAddress($user->email);
                     $mailer->includeHTMLTemplate('email.reset-password', ['link' => $link]);
                     $mailer->send();
                     // errors handled within
                     // Show Message
                     $alert = new Alert(Alert::SUCCESS);
                     $alert->addMessage('Email Sent');
                 } else {
                     $alert = new Alert(Alert::ERROR);
                     $alert->addMessage('Too Many Attempts, Please Try Again Later');
                 }
                 $this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]);
             } else {
                 $alert = new Alert(Alert::ERROR);
                 $alert->addMessage('Email is Invalid/Non-Existent');
                 $this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]);
             }
         }
     } else {
         if ($this->request->isQueryArgSet('token')) {
             $user = new UserModel();
             if ($user->getUserForPasswordResetToken($this->request->queryArgValue('token'))) {
                 $this->view->includeTemplate('auth.reset-password.password', ['app_name' => AppConfig::getValue('app_name')]);
             } else {
                 AppController::redirect(RouteController::fqURL('resetPassword'), ['status' => 'token-expired']);
             }
         } else {
             if ($this->request->isQueryArgSet('status') && $this->request->queryArgValue('status') == 'token-expired') {
                 $alert = new Alert(Alert::ERROR);
                 $alert->addMessage('Token is Invalid/Expired, Please Request a New One');
             }
             $this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => isset($alert) ? $alert : null]);
         }
     }
     $this->view->render(true);
 }
 private function getCustomer(UserModel $user)
 {
     // Redirect to Start... (not a customer)
     if (!$user->isStripeCustomer()) {
         AppController::redirect(RouteController::fqURL('subscription.manage'));
     }
     try {
         \Stripe\Stripe::setApiKey(AppConfig::getValue('stripe_secret_api_key'));
         // Attempt to Fetch Customer...
         $customer = \Stripe\Customer::retrieve($user->getStripeData()->customer_id);
         // Exisitng, Deleted?
         if ($customer->deleted) {
             $user->stripe_customer_id = null;
             $user->setStripeData(null);
             $user->save();
             // Redirect to Start...
             AppController::redirect(RouteController::fqURL('subscription.manage'));
         } else {
             return $customer;
         }
     } catch (\Stripe\Error\Card $exception) {
         $this->logStripeException($exception, $customer->id);
     } catch (\Stripe\Error\InvalidRequest $exception) {
         $this->logStripeException($exception, $customer->id);
     } catch (\Stripe\Error\Authentication $exception) {
         $this->logStripeException($exception, $customer->id);
     } catch (\Stripe\Error\ApiConnection $exception) {
         $this->logStripeException($exception, $customer->id);
     } catch (\Stripe\Error\Base $exception) {
         $this->logStripeException($exception, $customer->id);
     }
 }