Commit 45f2b398 authored by Vipul Basapati's avatar Vipul Basapati

Added new way in Flash.vue to not hide the flash message. Added the same...

Added new way in Flash.vue to not hide the flash message. Added the same functionality in GeneralException to store a  variable
parent 43e3781f
......@@ -9,4 +9,28 @@ use Exception;
*/
class GeneralException extends Exception
{
/**
* message
*
* @var string
*/
public $message;
/**
* dontHide
*
* @var bool
*/
public $dontHide;
/**
* Constructor function
*
* @param string $message
* @param boolean $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());
}
......
......@@ -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();
......
......@@ -6,46 +6,49 @@
<script>
export default {
props: ["message", "type"],
data() {
return {
body: "",
typeClass: "",
show: false
};
},
created() {
var context = this;
if (this.message && this.type) {
this.flash(this.message, this.type);
}
window.events.$on("flash", function(message, type) {
context.flash(message, type);
});
},
methods: {
flash(message, type) {
if (! type) {
type = "info";
}
this.body = message;
this.typeClass = "alert alert-" + type;
this.show = true;
this.hide();
},
hide() {
setTimeout(() => {
this.show = false;
}, 3000);
}
}
props: ["message", "type", "dontHide"],
data() {
return {
body: "",
typeClass: "",
show: false
};
},
created() {
const context = this;
if (this.message && this.type) {
this.flash(this.message, this.type, this.dontHide);
}
window.events.$on("flash", function(message, type) {
context.flash(message, type);
});
},
methods: {
flash(message, type, dontHide = false) {
if (! type) {
type = "info";
}
this.body = message;
this.typeClass = "alert alert-" + type;
this.show = true;
if(! dontHide) {
this.hide();
}
},
hide() {
setTimeout(() => {
this.show = false;
}, 3000);
}
}
};
</script>
@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