Skip to content

Commit

Permalink
Merge pull request #143 from byordereurope/master
Browse files Browse the repository at this point in the history
Updated signup_mail and signup_confirm for easier changes instead of messing with the controller.
  • Loading branch information
andrew13 committed Oct 7, 2013
2 parents da61e6b + df6289b commit 77c9d44
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ For MongoDB support see [Confide Mongo](https://github.com/Zizaco/confide-mongo)

**Warning:**

Standard the confirm email is not being send. So if you want only confirmed users to login, in your UserController, instead of simply calling logAttempt( $input ), call logAttempt( $input, true ). The second parameter stands for "confirmed_only".
Standard the confirm email is being send. And we require them to be confirmed.
It is easy to change this in the confide config-file.
Both values signup_email and signup_confirm are set to true in the config-file.
Change it to false if you do not want to send them an email and they do not need
to be confirmed to be able to login to the website.

## Quick start

Expand Down Expand Up @@ -226,6 +230,9 @@ To change the validation rules of the User model you can take a look at [Ardent]

Feel free to add more fields to your table and to the validation array. Then you should build your own sign-up form with the additional fields.

NOTE: If you add fields to your validation rules into your model like above, do not forget you have to add those fields to the UserController store function also. If you forget this, the form will always return with an error.
Example: $user->terms = Input::get('terms');

#### Passing additional information to the make methods

If you want to pass additional parameters to the forms, you can use an alternate syntax to achieve this.
Expand Down
10 changes: 6 additions & 4 deletions src/Zizaco/Confide/ConfideUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,12 @@ public function afterSave($success, $forced = false)
{
if (! $this->confirmed && ! static::$app['cache']->get('confirmation_email_'.$this->id) )
{
$view = static::$app['config']->get('confide::email_account_confirmation');

$this->sendEmail( 'confide::confide.email.account_confirmation.subject', $view, array('user' => $this) );

// on behalf or the config file we should send and email or not
if (static::$app['config']->get('confide::signup_email') == true)
{
$view = static::$app['config']->get('confide::email_account_confirmation');
$this->sendEmail( 'confide::confide.email.account_confirmation.subject', $view, array('user' => $this) );
}
// Save in cache that the email has been sent.
$signup_cache = (int)static::$app['config']->get('confide::signup_cache');
if ($signup_cache !== 0)
Expand Down
25 changes: 25 additions & 0 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,29 @@
|
*/
'signup_cache' => 120,

/*
|--------------------------------------------------------------------------
| Signup E-mail and confirmation (true or false)
|--------------------------------------------------------------------------
|
| By default a signup e-mail will be send by the system, however if you
| do not want this to happen, change the line below in false and handle
| the confirmation using another technique, for example by using the IPN
| from a payment-processor. Very usefull for websites offering products.
|
| signup_email:
| is for the transport of the email, true or false
| If you want to use an IPN to trigger the email, then set it to false
|
| signup_confirm:
| is to decide of a member needs to be confirmed before he is able to login
| so when you set this to true, then a member has to be confirmed before
| he is able to login, so if you want to use an IPN for confirmation, be
| sure that the ipn process also changes the confirmed flag in the member
| table, otherwise they will not be able to login after the payment.
|
*/
'signup_email' => true,
'signup_confirm' => true,
);
3 changes: 2 additions & 1 deletion src/views/generators/controller.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ public function {{ (! $restful) ? 'do_login' : 'postLogin' }}()
// If you wish to only allow login from confirmed users, call logAttempt
// with the second parameter as true.
// logAttempt will check if the 'email' perhaps is the username.
if ( Confide::logAttempt( $input ) )
// Get the value from the config file instead of changing the controller
if ( Confide::logAttempt( $input, Config::get('confide::signup_confirm') ) )
{
// If the session 'loginRedirect' is set, then redirect
// to that route. Otherwise redirect to '/'
Expand Down

0 comments on commit 77c9d44

Please sign in to comment.