Unverified Commit aae971c8 authored by Vipul Basapati's avatar Vipul Basapati Committed by GitHub

Merge pull request #279 from bvipul/develop

Mailables and New Flash function
parents f685c403 04e8d0d3
APP_NAME="Laravel Admin Panel"
APP_SHORT_NAME="LAP"
APP_ENV=local
APP_KEY=base64:O+TrollIDwasHEREtMG9kBc+/Q32exQLusNVhnq558w=
APP_DEBUG=true
......
......@@ -9,4 +9,29 @@ use Exception;
*/
class GeneralException extends Exception
{
/**
* message.
*
* @var string
*/
public $message;
/**
* dontHide.
*
* @var bool
*/
public $dontHide;
/**
* Constructor function.
*
* @param string $message
* @param bool $dontHide
*/
public function __construct($message, $dontHide = false)
{
$this->message = $message;
$this->dontHide = $dontHide;
}
}
......@@ -53,7 +53,6 @@ class Handler extends ExceptionHandler
*/
public function render($request, Exception $exception)
{
//dd($exception);
if (strpos($request->url(), '/api/') !== false) {
\Log::debug('API Request Exception - '.$request->url().' - '.$exception->getMessage().(!empty($request->all()) ? ' - '.json_encode($request->except(['password'])) : ''));
......@@ -112,6 +111,8 @@ class Handler extends ExceptionHandler
* All instances of GeneralException redirect back with a flash message to show a bootstrap alert-error
*/
if ($exception instanceof GeneralException) {
session()->flash('dontHide', $exception->dontHide);
return redirect()->back()->withInput()->withFlashDanger($exception->getMessage());
}
......
......@@ -31,7 +31,7 @@ class PagesController extends APIController
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : config('module.pages.table', 'pages').'created_at';
return PagesResource::collection(
$this->repository->getForDataTable()->orderBy($sortBy, $orderBy)->paginate($limit)
......
......@@ -21,7 +21,7 @@ class LoginController extends Controller
use AuthenticatesUsers;
/**
* @var CMSPagesRepository
* @var \App\Http\Utilities\PushNotification
*/
protected $notification;
......@@ -74,7 +74,7 @@ class LoginController extends Controller
if (!$user->isConfirmed()) {
access()->logout();
throw new GeneralException(trans('exceptions.frontend.auth.confirmation.resend', ['user_id' => $user->id]));
throw new GeneralException(trans('exceptions.frontend.auth.confirmation.resend', ['user_id' => $user->id]), true);
} elseif (!$user->isActive()) {
access()->logout();
......
......@@ -95,11 +95,12 @@ class ResetPasswordController extends Controller
/**
* Get the response for a successful password reset.
*
* @param \Illuminate\Http\Request $request
* @param string $response
*
* @return \Illuminate\Http\RedirectResponse
*/
protected function sendResetResponse($response)
protected function sendResetResponse($request, $response)
{
return redirect()->route(homeRoute())->withFlashSuccess(trans($response));
}
......
......@@ -34,21 +34,6 @@ class UserEventListener
\Log::info('User Registered: '.$event->user->full_name);
}
/**
* @param $event
*/
/*public function onRegistered($event)
{
\Log::info('User Registered: '.$event->user->first_name);
// Send email to the user
$options = [
'data' => $event->user,
'email_template_type' => 1,
];
createNotification('', 1, 2, $options);
}*/
/**
* @param $event
*/
......
......@@ -147,23 +147,22 @@ trait UserAttribute
switch ($this->status) {
case 0:
if (access()->allow('activate-user')) {
$name = $class == '' ? 'Active' : '';
$name = $class == '' ? 'Activate' : '';
return '<a class="'.$class.'" href="'.route('admin.access.user.mark', [$this, 1]).'"><i class="fa fa-check-square" data-toggle="tooltip" data-placement="top" title="'.trans('buttons.backend.access.users.activate').'"></i>'.$name.'</a>';
}
// No break
break;
case 1:
if (access()->allow('deactivate-user')) {
$name = ($class == '') ? 'Deactive' : '';
$name = ($class == '') ? 'Deactivate' : '';
return '<a class="'.$class.'" href="'.route('admin.access.user.mark', [$this, 0]).'"><i class="fa fa-square" data-toggle="tooltip" data-placement="top" title="'.trans('buttons.backend.access.users.deactivate').'"></i>'.$name.'</a>';
}
// No break
break;
default:
return '';
// No break
}
}
......
<?php
namespace App\Notifications\Frontend\Auth;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
/**
* Class UserChangedPassword.
*/
class UserChangedPassword extends Notification
{
use Queueable;
/**
* @var
*/
protected $password;
/**
* UserChangedPassword constructor.
*
* @param $password
*/
public function __construct($password)
{
$this->password = $password;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param \App\Models\Access\User\User $user
*
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($user)
{
return (new MailMessage())
->view('emails.changed-password', ['password' => $this->password]);
}
}
......@@ -52,6 +52,6 @@ class UserNeedsConfirmation extends Notification
$confirmation_url = route('frontend.auth.account.confirm', $user->confirmation_code);
return (new MailMessage())
->view('emails.template', ['confirmation_url' => $confirmation_url]);
->view('emails.user-confirmation', ['confirmation_url' => $confirmation_url]);
}
}
......@@ -50,10 +50,9 @@ class UserNeedsPasswordReset extends Notification
*/
public function toMail($notifiable)
{
$reset_password_route = route('frontend.auth.password.reset.form', $this->token);
return (new MailMessage())
->subject(app_name().': '.trans('strings.emails.auth.password_reset_subject'))
->line(trans('strings.emails.auth.password_cause_of_email'))
->action(trans('buttons.emails.auth.reset_password'), route('frontend.auth.password.reset.form', $this->token))
->line(trans('strings.emails.auth.password_if_not_requested'));
->view('emails.reset-password', ['reset_password_url' => $reset_password_route]);
}
}
......@@ -6,6 +6,7 @@ use App\Events\Frontend\Auth\UserConfirmed;
use App\Exceptions\GeneralException;
use App\Models\Access\User\SocialLogin;
use App\Models\Access\User\User;
use App\Notifications\Frontend\Auth\UserChangedPassword;
use App\Notifications\Frontend\Auth\UserNeedsConfirmation;
use App\Repositories\Backend\Access\Role\RoleRepository;
use App\Repositories\BaseRepository;
......@@ -286,13 +287,7 @@ class UserRepository extends BaseRepository
$user->password = bcrypt($input['password']);
if ($user->save()) {
$input['email'] = $user->email;
// Send email to the user
$options = [
'data' => $input,
'email_template_type' => 4,
];
createNotification('', $user->id, 2, $options);
$user->notify(new UserChangedPassword($input['password']));
return true;
}
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
<script>
export default {
props: ["message", "type"],
props: ["message", "type", "dontHide"],
data() {
return {
......@@ -17,9 +17,10 @@ export default {
},
created() {
var context = this;
const context = this;
if (this.message && this.type) {
this.flash(this.message, this.type);
this.flash(this.message, this.type, this.dontHide);
}
window.events.$on("flash", function(message, type) {
......@@ -28,7 +29,7 @@ export default {
},
methods: {
flash(message, type) {
flash(message, type, dontHide = false) {
if (! type) {
type = "info";
......@@ -38,7 +39,9 @@ export default {
this.typeClass = "alert alert-" + type;
this.show = true;
if(! dontHide) {
this.hide();
}
},
hide() {
......
@extends('emails.layouts.app')
@section('content')
<div class="content">
<td align="left">
<table border="0" width="80%" align="center" cellpadding="0" cellspacing="0" class="container590">
<tr>
<td align="left" style="color: #888888; width:20px; font-size: 16px; line-height: 24px;">
<!-- section text ======-->
<p style="line-height: 24px; margin-bottom:15px;">
Hello!
</p>
<p style="line-height: 24px; margin-bottom:20px;">
Your Password has successfully been changed to : {{ $password }}
</p>
<p style="line-height: 24px; margin-bottom:20px;">
If you did not change your password, try resetting your password using above password.
</p>
<p style="line-height: 24px">
Regards,</br>
@yield('title', app_name())
</p>
<br/>
@include('emails.layouts.footer')
</td>
</tr>
</table>
</td>
</div>
@endsection
\ No newline at end of file
......@@ -5,7 +5,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" />
<meta name="viewport" content="width=600,initial-scale = 2.3,user-scalable=no">
<!--[if !mso]><!-- -->
<!--<![if !mso]-->
<link href="https://fonts.googleapis.com/css?family=Fira+Sans|Fira+Sans+Condensed|Raleway" rel="stylesheet">
<!--<![endif]-->
......@@ -53,6 +53,7 @@
font-size: 14px;
border: 0;
padding:10px;
width: 100%;
}
.lap{
......@@ -67,9 +68,30 @@
margin-right: 25px;
}
.content{
.main-header {
color: #343434;
font-size: 24px;
font-weight:300;
line-height: 35px;
}
.main-header .brand {
letter-spacing: 5px;
font-size: 28px;
}
.main-header .tagline {
font-size: 16px;
}
.small {
font-size: 10px;
}
.center {
text-align: center;
}
/* ----------- responsivity ----------- */
@media only screen and (max-width: 640px) {
......@@ -133,8 +155,6 @@
}
</style>
</head>
<body class="respond" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div class="container">
......@@ -143,26 +163,19 @@
<td align="center">
<table border="0" align="center" width="590" cellpadding="0" cellspacing="0" class="container590">
<tr>
<td align="center" style="color: #343434; font-size: 24px; font-family: Quicksand, Calibri, sans-serif; font-weight:700;letter-spacing: 3px; line-height: 35px;"
<td align="center">
<table border="0" width="40" align="center" cellpadding="0" cellspacing="0" bgcolor="eeeeee">
<tr>
<td align="center" style=""
class="main-header">
<!-- section text ======-->
<div class="brand">{{ env('APP_SHORT_NAME', 'LAP') }}</div>
<div style="line-height: 35px">
<div class="tagline">
{{ app_name() }}
</div>
</td>
</tr>
<tr>
<td height="10" style="font-size: 10px; line-height: 10px;">&nbsp;</td>
</tr>
<tr>
<td align="center">
<table border="0" width="40" align="center" cellpadding="0" cellspacing="0" bgcolor="eeeeee">
<tr>
<td height="2" style="font-size: 2px; line-height: 2px;">&nbsp;</td>
</tr>
</table>
</td>
</tr>
......@@ -172,72 +185,7 @@
</tr>
<tr>
<div class="content">
<td align="left">
<table border="0" width="80%" align="center" cellpadding="0" cellspacing="0" class="container590">
<tr>
<td align="left" style="color: #888888; width:20px; font-size: 16px; font-family: 'Work Sans', Calibri, sans-serif; line-height: 24px;">
<!-- section text ======-->
<p style="line-height: 24px; margin-bottom:15px;">
Hello!
</p>
<p style="line-height: 24px; margin-bottom:20px;">
Click here to confirm your account:
</p>
<table border="0" align="center" width="180" cellpadding="0" cellspacing="0" bgcolor="5caad2" style="margin-bottom:20px;">
<tr>
<td height="10" style="font-size: 10px; line-height: 10px;">&nbsp;</td>
</tr>
<tr>
<td align="center" style="color: #ffffff; font-size: 14px; font-family: 'Work Sans', Calibri, sans-serif; line-height: 22px; letter-spacing: 2px;">
<!-- main section button -->
<div style="line-height: 22px;">
<a href="{{ $confirmation_url }}" style="color: #ffffff; text-decoration: none;">Confirm Account</a>
</div>
</td>
</tr>
<tr>
<td height="10" style="font-size: 10px; line-height: 10px;">&nbsp;</td>
</tr>
</table>
<p style="line-height: 24px; margin-bottom:20px;">
Thank you for using our application!
</p>
<p style="line-height: 24px">
Regards,</br>
@yield('title', app_name())
</p>
<br><br>
<p style="line-height: 24px; margin-bottom:20px;">
If you’re having trouble clicking the "Confirm Account" button, copy and paste the URL below into your web browser:
</p>
<p style="line-height: 24px; margin-bottom:20px;">
<a href="{{ $confirmation_url }}" target="_blank" class="lap">
{{ $confirmation_url}}
</a>
</p>
<p style="line-height: 24px; margin-bottom: 20px;">
©2018 <a href="" target="_blank" class="lap">@yield('title', app_name())</a>
All Rights are Reserved.
</p>
</td>
</tr>
</table>
</td>
</div>
@yield('content')
</tr>
</table>
</td>
......
<p class="small center" style="line-height: 24px; margin-bottom: 20px;">
©2018 <a href="{{ url('/') }}" target="_blank" class="lap">@yield('title', app_name())</a>
All Rights are Reserved.
</p>
\ No newline at end of file
@extends('emails.layouts.app')
@section('content')
<div class="content">
<td align="left">
<table border="0" width="80%" align="center" cellpadding="0" cellspacing="0" class="container590">
<tr>
<td align="left" style="color: #888888; width:20px; font-size: 16px; line-height: 24px;">
<!-- section text ======-->
<p style="line-height: 24px; margin-bottom:15px;">
Hello!
</p>
<p style="line-height: 24px; margin-bottom:20px;">
You are receiving this email because we received a password reset request for your account.
</p>
<table border="0" align="center" width="180" cellpadding="0" cellspacing="0" bgcolor="5caad2" style="margin-bottom:20px; background: #003bd7; border-radius: 5px;">
<tr>
<td height="10" style="font-size: 10px; line-height: 10px;">&nbsp;</td>
</tr>
<tr>
<td align="center" style="color: #ffffff; font-size: 14px; line-height: 22px;letter-spacing: 1px;font-weight: bold;">
<!-- main section button -->
<div style="line-height: 22px;">
<a href="{{ $reset_password_url }}" style="color: #ffffff; text-decoration: none;">Reset Password</a>
</div>
</td>
</tr>
<tr>
<td height="10" style="font-size: 10px; line-height: 10px;">&nbsp;</td>
</tr>
</table>
<p style="line-height: 24px; margin-bottom:20px;">
If you did not request a password reset, no further action is required.
</p>
<p style="line-height: 24px">
Regards,</br>
@yield('title', app_name())
</p>
<br/>
<p class="small" style="line-height: 24px; margin-bottom:20px;">
If you’re having trouble clicking the "Reset Password" button, copy and paste the URL below into your web browser:
</p>
<p class="small" style="line-height: 24px; margin-bottom:20px;">
<a href="{{ $reset_password_url }}" target="_blank" class="lap">
{{ $reset_password_url}}
</a>
</p>
@include('emails.layouts.footer')
</td>
</tr>
</table>
</td>
</div>
@endsection
\ No newline at end of file
@extends('emails.layouts.app')
@section('content')
<div class="content">
<td align="left">
<table border="0" width="80%" align="center" cellpadding="0" cellspacing="0" class="container590">
<tr>
<td align="left" style="color: #888888; width:20px; font-size: 16px; line-height: 24px;">
<!-- section text ======-->
<p style="line-height: 24px; margin-bottom:15px;">
Hello!
</p>
<p style="line-height: 24px; margin-bottom:20px;">
Click here to confirm your account:
</p>
<table border="0" align="center" width="180" cellpadding="0" cellspacing="0" bgcolor="5caad2" style="margin-bottom:20px; background: #003bd7; border-radius: 5px;">
<tr>
<td height="10" style="font-size: 10px; line-height: 10px;">&nbsp;</td>
</tr>
<tr>
<td align="center" style="color: #ffffff; font-size: 14px; line-height: 22px;letter-spacing: 1px;font-weight: bold;">
<!-- main section button -->
<div style="line-height: 22px;">
<a href="{{ $confirmation_url }}" style="color: #ffffff; text-decoration: none;">Confirm Account</a>
</div>
</td>
</tr>
<tr>
<td height="10" style="font-size: 10px; line-height: 10px;">&nbsp;</td>
</tr>
</table>
<p style="line-height: 24px; margin-bottom:20px;">
Thank you for using our application!
</p>
<p style="line-height: 24px">
Regards,</br>
@yield('title', app_name())
</p>
<br/>
<p class="small" style="line-height: 24px; margin-bottom:20px;">
If you’re having trouble clicking the "Confirm Account" button, copy and paste the URL below into your web browser:
</p>
<p class="small" style="line-height: 24px; margin-bottom:20px;">
<a href="{{ $confirmation_url }}" target="_blank" class="lap">
{{ $confirmation_url}}
</a>
</p>
@include('emails.layouts.footer')
</td>
</tr>
</table>
</td>
</div>
@endsection
\ No newline at end of file
@php
$message = '';
$type = '';
@endphp
$dontHide = false;
if(session()->has('dontHide')) {
$dontHide = session()->get('dontHide');
}
@endphp
@if ($errors->any())
@php
$type = 'danger';
......@@ -80,4 +84,4 @@
@endif
<!-- Flash Message Vue component -->
<flash message="{!! $message !!}" type="{{ $type }}"></flash>
\ No newline at end of file
<flash message="{!! $message !!}" type="{{ $type }}" dont-hide="{{ $dontHide }}"></flash>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment