Skip to content

Commit

Permalink
Merge pull request #39 from civictechro/release/0.0.3
Browse files Browse the repository at this point in the history
Mail templates and pass reseting
  • Loading branch information
tudor-rusu authored Mar 12, 2018
2 parents c02dca0 + e951a46 commit 6446419
Show file tree
Hide file tree
Showing 44 changed files with 1,435 additions and 132 deletions.
2 changes: 1 addition & 1 deletion api-man/app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LoginController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = '/admin';

/**
* Create a new controller instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ResetPasswordController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = '/admin';

/**
* Create a new controller instance.
Expand Down
28 changes: 28 additions & 0 deletions api-man/app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}

/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('home');
}
}
46 changes: 46 additions & 0 deletions api-man/app/Mail/DsuResetPassword.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class DsuResetPassword extends Mailable
{
use Queueable, SerializesModels;

protected $token;
protected $notifiable;

/**
* Create a new message instance.
*
* @return void
*/
public function __construct($token, $notifiable)
{
$this->token = $token;
$this->notifiable = $notifiable;
}

/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('emails.users.dsuresetpassword', [
'greeting' => __('mail.greetings.informal') . ' ' . $this->notifiable->name . ',',
'body_message' => __('mail.body.reset_password'),
'level' => 'error',
'actionUrl' => url(config('app.url').route('password.reset', $this->token, false)),
'actionText' => __('mail.buttons.reset_password'),
'salutation' => __('mail.greetings.salutation'),
'signature' => __('mail.greetings.signature_tehnic'),
'subcopy_content' => __('mail.subcopy.reset_password', ['actionText' => __('mail.buttons.reset_password')]),
]);
}
}
58 changes: 58 additions & 0 deletions api-man/app/Notifications/DsuResetPassword.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use App\Mail\DsuResetPassword as Mailable;

class DsuResetPassword extends Notification
{
use Queueable;

/**
* The password reset token.
*
* @var string
*/
public $token;

/**
* Create a notification instance.
*
* @param string $token
* @return void
*/
public function __construct($token)
{
$this->token = $token;
}

/**
* Get the notification's channels.
*
* @param mixed $notifiable
* @return array|string
*/
public function via($notifiable)
{
return ['mail'];
}

/**
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$subject = sprintf("[%s] %s", config('app.name'), __('mail.subject.reset_password'));
return (new Mailable($this->token, $notifiable))
->from('[email protected]', config('app.name'))
->subject($subject)
->to($notifiable->email);
}
}
12 changes: 12 additions & 0 deletions api-man/app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use App\Notifications\DsuResetPassword as ResetPasswordNotification;

class User extends \TCG\Voyager\Models\User
{
Expand All @@ -26,4 +27,15 @@ class User extends \TCG\Voyager\Models\User
protected $hidden = [
'password', 'remember_token',
];

/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPasswordNotification($token));
}
}
19 changes: 19 additions & 0 deletions api-man/resources/lang/ro/auth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Authentication Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are used during authentication for various
| messages that we need to display to the user. You are free to modify
| these language lines according to your application's requirements.
|
*/

'failed' => 'These credentials do not match our records.',
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',

];
22 changes: 22 additions & 0 deletions api-man/resources/lang/ro/mail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

return [
'subject' => [
'reset_password' => 'Resetarea parolei',
],
'greetings' => [
'informal' => 'Bună',
'salutation' => 'Toate cele bune,',
'signature_tehnic' => 'Echipa tehnică',
],
'body' => [
'reset_password' => 'Primești acest e-mail deoarece am primit o solicitare de resetare a parolei pentru contul tău. Dacă nu ai cerut resetarea parolei, atunci poți ignora acest mesaj.',
'rights_reserved' => 'Toate drepturile rezervate',
],
'buttons' => [
'reset_password' => 'Resetează parola',
],
'subcopy' => [
'reset_password' => 'Dacă întâmpini probleme la clic pe butonul :actionText, copiază și inserează adresa URL de mai jos în browser-ul tău:',
],
];
19 changes: 19 additions & 0 deletions api-man/resources/lang/ro/pagination.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Pagination Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are used by the paginator library to build
| the simple pagination links. You are free to change them to anything
| you want to customize your views to better match your application.
|
*/

'previous' => '&laquo; Precedenta',
'next' => 'Următoarea &raquo;',

];
22 changes: 22 additions & 0 deletions api-man/resources/lang/ro/passwords.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Password Reset Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are the default lines which match reasons
| that are given by the password broker for a password update attempt
| has failed, such as for an invalid token or invalid new password.
|
*/

'password' => 'Parola trebuie să conțină cel puțin șase caractere și să coincidă cu confirmarea.',
'reset' => 'Parola a fost resetată!',
'sent' => 'Link-ul de resetare a parolei a fost trimis pe email!',
'token' => 'Acest token de resetare a parolei este invalid.',
'user' => "Nu am găsit un utilizator cu această adresă de email.",

];
121 changes: 121 additions & 0 deletions api-man/resources/lang/ro/validation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Validation Language Lines
|--------------------------------------------------------------------------
|
| The following language lines contain the default error messages used by
| the validator class. Some of these rules have multiple versions such
| as the size rules. Feel free to tweak each of these messages here.
|
*/

'accepted' => 'The :attribute must be accepted.',
'active_url' => 'The :attribute is not a valid URL.',
'after' => 'The :attribute must be a date after :date.',
'after_or_equal' => 'The :attribute must be a date after or equal to :date.',
'alpha' => 'The :attribute may only contain letters.',
'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.',
'alpha_num' => 'The :attribute may only contain letters and numbers.',
'array' => 'The :attribute must be an array.',
'before' => 'The :attribute must be a date before :date.',
'before_or_equal' => 'The :attribute must be a date before or equal to :date.',
'between' => [
'numeric' => 'The :attribute must be between :min and :max.',
'file' => 'The :attribute must be between :min and :max kilobytes.',
'string' => 'The :attribute must be between :min and :max characters.',
'array' => 'The :attribute must have between :min and :max items.',
],
'boolean' => 'The :attribute field must be true or false.',
'confirmed' => 'Parola și confirmarea acesteia nu coincid.',
'date' => 'The :attribute is not a valid date.',
'date_format' => 'The :attribute does not match the format :format.',
'different' => 'The :attribute and :other must be different.',
'digits' => 'The :attribute must be :digits digits.',
'digits_between' => 'The :attribute must be between :min and :max digits.',
'dimensions' => 'The :attribute has invalid image dimensions.',
'distinct' => 'The :attribute field has a duplicate value.',
'email' => 'Adresa de :attribute trebuie sa fie o adresă validă.',
'exists' => 'The selected :attribute is invalid.',
'file' => 'The :attribute must be a file.',
'filled' => 'The :attribute field must have a value.',
'image' => 'The :attribute must be an image.',
'in' => 'The selected :attribute is invalid.',
'in_array' => 'The :attribute field does not exist in :other.',
'integer' => 'The :attribute must be an integer.',
'ip' => 'The :attribute must be a valid IP address.',
'ipv4' => 'The :attribute must be a valid IPv4 address.',
'ipv6' => 'The :attribute must be a valid IPv6 address.',
'json' => 'The :attribute must be a valid JSON string.',
'max' => [
'numeric' => 'The :attribute may not be greater than :max.',
'file' => 'The :attribute may not be greater than :max kilobytes.',
'string' => 'The :attribute may not be greater than :max characters.',
'array' => 'The :attribute may not have more than :max items.',
],
'mimes' => 'The :attribute must be a file of type: :values.',
'mimetypes' => 'The :attribute must be a file of type: :values.',
'min' => [
'numeric' => 'The :attribute must be at least :min.',
'file' => 'The :attribute must be at least :min kilobytes.',
'string' => 'The :attribute must be at least :min characters.',
'array' => 'The :attribute must have at least :min items.',
],
'not_in' => 'The selected :attribute is invalid.',
'numeric' => 'The :attribute must be a number.',
'present' => 'The :attribute field must be present.',
'regex' => 'The :attribute format is invalid.',
'required' => 'The :attribute field is required.',
'required_if' => 'The :attribute field is required when :other is :value.',
'required_unless' => 'The :attribute field is required unless :other is in :values.',
'required_with' => 'The :attribute field is required when :values is present.',
'required_with_all' => 'The :attribute field is required when :values is present.',
'required_without' => 'The :attribute field is required when :values is not present.',
'required_without_all' => 'The :attribute field is required when none of :values are present.',
'same' => 'The :attribute and :other must match.',
'size' => [
'numeric' => 'The :attribute must be :size.',
'file' => 'The :attribute must be :size kilobytes.',
'string' => 'The :attribute must be :size characters.',
'array' => 'The :attribute must contain :size items.',
],
'string' => 'The :attribute must be a string.',
'timezone' => 'The :attribute must be a valid zone.',
'unique' => 'The :attribute has already been taken.',
'uploaded' => 'The :attribute failed to upload.',
'url' => 'The :attribute format is invalid.',

/*
|--------------------------------------------------------------------------
| Custom Validation Language Lines
|--------------------------------------------------------------------------
|
| Here you may specify custom validation messages for attributes using the
| convention "attribute.rule" to name the lines. This makes it quick to
| specify a specific custom language line for a given attribute rule.
|
*/

'custom' => [
'attribute-name' => [
'rule-name' => 'custom-message',
],
],

/*
|--------------------------------------------------------------------------
| Custom Validation Attributes
|--------------------------------------------------------------------------
|
| The following language lines are used to swap attribute place-holders
| with something more reader friendly such as E-Mail Address instead
| of "email". This simply helps us make messages a little cleaner.
|
*/

'attributes' => [],

];
Loading

0 comments on commit 6446419

Please sign in to comment.