8

sort of installed Sentinel ( i say sort of because I dont understand one part that says:

Sentinel ships with default implementations for illuminate/database, in order to use it, make sure you require it on your composer.json file.

// Import the necessary classes

use Cartalyst\Sentinel\Native\Facades\Sentinel;
use Illuminate\Database\Capsule\Manager as Capsule;

// Include the composer autoload file

require 'vendor/autoload.php';

Question 1: where do I write that code ?

Question 2:, what I care most now is how to make something out of this, regarding Registration, Activation etc. I would have expected to have a link created that is sent to your email and upon clicking on it you activate it. But all I can see it says is this:

$credentials = [
    'email'    => 'john.doe@example.com',
    'password' => 'password',
];

$user = Sentinel::register($credentials);

or if Also activate:

$credentials = [
    'email'    => 'john.doe@example.com',
    'password' => 'password',
];

$user = Sentinel::registerAndActivate($credentials);

I am supposed to write that in the Controller when I get the input ? and what about the email activation ?

patricio
  • 350
  • 2
  • 5
  • 13
  • This is for L4, but it's a good example of how to use the Sentinel package: https://github.com/cartalyst/demo-sentinel – daviestar Feb 15 '16 at 13:29

4 Answers4

5

GETTING SENTINEL AUTHENTICATION-AUTHORIZATION PACKAGE REALLY RUNNING FOR TOTAL BEGINNERS:

https://github.com/rydurham/Sentinel/blob/master/readme.md

It is the very author. If you had installed following any other site's instructions you had better removed your installation and run again composer update so that it gets rid off any traces of sentinel.

Install following ryan durham steps. (they are at least valid as of the date I post).

Once you do that, you will find there are already pre-created blade pages. You can go to Register as the first one, and enter your data (having configured your DB and Mail parameters before of course).

Also, at the Mail.php in the very latest version of Laravel, there is one parameter changed compared to former versions: the one about encryption. In my case I needed to set it as it was in the past, simply:

'encryption' => 'ssl' and NOT AS 'encryption' => env('MAIL_ENCRYPTION', $_ENV['MAIL_ENCRYPTION']

in the second case it won't be able to connect to your mail server.

This is saying, yes, that Sentinel already has that pre-built. Once you fill out the Registration Form, you will see yourself added to the Database but still not activated. Then in your mail box you will have that link I talked about. Click on it and your account will be activated.

patricio
  • 350
  • 2
  • 5
  • 13
  • 1
    I don't think he is refering to rydurham sentinel (which is an old implementation of Sentry 2 for laravel, but rather Sentinel, what used to be [Cartalyst's premium package](https://cartalyst.com/manual/sentinel/2.0) and has recently been opensourced. Sentinel 2 is outdated and unsupported and should not be used. – Victor Aug 05 '15 at 15:56
  • Hello Victor. About a week ago I installed it from Ryan Durham right where the link I indicated. It works fine for me. Do you mean that what I am using is unsupported and outdated? – patricio Aug 05 '15 at 18:35
  • 1
    Hey Patricio. If you are using Senty 2, then yes. Cartalyst developed Sentry 2 a while back and what was supposed to be Sentry 3 became Sentinel. Until recently Sentinel was a part of Cartalyst's arsenal (which you have to pay for, but they have recently opensourced it). The Ryan Durham's package have the same name, but it's actually an integration between Sentry 2 and Laravel. Although is an opensource project, Sentry 2 is no longer been officially maintained and you probably won't get any security updates, unless the durham/sentinel package itself gets updated. – Victor Aug 05 '15 at 18:41
4

The following code:

use Cartalyst\Sentinel\Native\Facades\Sentinel; use Illuminate\Database\Capsule\Manager as Capsule;

Is for people trying to use the package natively. Since you are using laravel, you don't need this. Please make sure you follow the laravel-specific instructions.

Because You've tagged laravel-5 in your question, I'm assuming that this is what you are using. In that case, first add this to your composer.json: composer require cartalyst/sentinel "2.0.*" and the following to your config/app.php file:

To the $providers array: 'Cartalyst\Sentinel\Laravel\SentinelServiceProvider',

And to the $alias~ array :

'Activation' => 'Cartalyst\Sentinel\Laravel\Facades\Activation', 'Reminder' => 'Cartalyst\Sentinel\Laravel\Facades\Reminder', 'Sentinel' => 'Cartalyst\Sentinel\Laravel\Facades\Sentinel',

Once you've done this, you can publish and migrate the package. You will also need to extendend Cartalyst\Sentinel\Users\EloquentUser on your user model instead of Eloquent. You will need to do the same if you are using a "roles" model.

For more information, follow the documentation: https://cartalyst.com/manual/sentinel/2.0#laravel-5

make sure you are on the correct version: 2.0 for Laravel 5 and 1.0 for laravel 4.*

In regards to your second question, you will have to send an e-mail to the client with the activation code (usually the code is hidden as a query string or something, so the user don't necessarily need to have knowledge of it) and than you do the activation using the code. Or if you prefer you can authenticate automatically once they sign up.

Read more upon activation on their documentation, if you still can't figure out we are here to help, but try for yourself first.

Victor
  • 556
  • 1
  • 10
  • 23
4

Take a look at this package :
https://github.com/srlabs/centaur
it will help you get up and running with cartalyst/sentinel

Yassin Mokni
  • 354
  • 1
  • 6
  • 16
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes – slfan Feb 22 '16 at 22:06
1

I know this post is old, but similar to srlabs/centaur, you can use Sentinel Centurion.

It lets you quickly scaffold authentication, registration, permission/role/user management, forgot password, activation emails, etc with Cartalyst Sentinel.

MTran
  • 1,799
  • 2
  • 17
  • 21