login.blade.php 12.8 KB
<?php 
use \App\Models\User;

if(Input::get('sendotp')=="1")
{
	$otpuser=trim(Input::get('otpuser'));
	$user=User::where('username','=',$otpuser)->first();
	if($user)
	{
		$otpemail=$user->email;
		$otp=rand(100000, 999999);
		
		$user->password=Hash::make($otp);
		
		$meta=$user->meta();
		if(!isset($meta['otp_array']))$meta['otp_array']=array();
		if(!isset($meta['otp_array'][date('Ymd')])){$meta['otp_array']=array();$meta['otp_array'][date('Ymd')]=0;}
		$meta['otp_array'][date('Ymd')]++;
		
		if($meta['otp_array'][date('Ymd')]<=3)
		{
		$user->meta=json_encode($meta);
		$user->save();
		
		Mail::send('emails.notification', 
				array(
						'heloname'=>'',
						'line1'=>'Your OTP for Login : '.$otp.' ',
						'line2'=>'Please visit <a href="'.URL::to('/').'"><b>'.Config::get("app.name").' </b></a> and You can login using this OTP.',
						'line3'=>'',
						'notifytype'=>'OTP'), function($message) use ($otpemail)
								{
										$message->to($otpemail,$otpemail);
										$message->subject(Config::get("app.name")." OTP for Login");
								});
		echo "$(\"#alertdiv\").html('<div class=\"alert alert-success\"><button type=button class=close data-dismiss=alert>&times;</button><strong>Success</strong> OTP Sent to ($otpemail)</div>');";
		}
		else echo "$(\"#alertdiv\").html('<div class=\"alert alert-danger\"><button type=button class=close data-dismiss=alert>&times;</button><strong>Failed</strong> Too many reuests ($otpemail), please try after 24 hrs</div>');";
	}
	else echo "$(\"#alertdiv\").html('<div class=\"alert alert-danger\"><button type=button class=close data-dismiss=alert>&times;</button><strong>Failed</strong> Invalid User </div>');";
}
else
{

?>

@include('layout.header')


<style>
    body {
        background: url(assets/images/main.jpg) no-repeat center center fixed;
        -webkit-background-size: cover;
        -moz-background-size: cover;
        -o-background-size: cover;
        background-size: cover;
}
    .layout-app .col-separator{
        background: url(assets/images/main.jpg) no-repeat center center fixed;
        -webkit-background-size: cover;
        -moz-background-size: cover;
        -o-background-size: cover;
        background-size: cover;
        
    }
    html.app .layout-app .col-separator{
        margin:0px !important;
    }
    .blur_bg{
        
    }
    html.app .layout-app{
        top: 0px;
        bottom: 0px;
    }
    .login{
        background: #fff;
        border-radius: 2px;
        top: 15%;
        -webkit-box-shadow: 0px 7px 22px 0px rgb(131, 151, 167);
        -moz-box-shadow: 0px 7px 22px 0px rgb(131, 151, 167);
        box-shadow: 0px 7px 22px 0px rgb(131, 151, 167);
}
    .login_head{
        background: #fff;
    border-radius: 2px 2px 0px 0;
        margin: 0 -5px;
    }
    .login_head img{
            margin: 0 auto;
    display: block;
    padding: 20px 0px 0px;
    border: 0px;
        height:70px;
    }
    .login_head span{
        color: #505050;
        display: block;
        text-align: center;
        margin-top: 10px;
        font-size: 15px;
        text-transform: uppercase;
        font-weight: 600;
    }
    .login_head  p{
        font-family: 'Open-Sans', sans-serif;
        font-weight: 400;
        line-height: 30px;
        font-size: 15px;
        color: #505050;
        -webkit-box-shadow: inset 0px -2px 10px -8px rgba(20,20,20,1);
        -moz-box-shadow: inset 0px -2px 10px -8px rgba(20,20,20,1);
        box-shadow: inset 0px -2px 10px -8px rgba(20,20,20,1);
    }
    .panel{
        background: transparent;
        border: 0px;
        box-shadow: 0 0px 0px rgba(0, 0, 0, 0.05);
        -webkit-box-shadow: 0 0px 0px rgba(0, 0, 0, 0.05);
    }
    .form-control::-webkit-input-placeholder {
   color: #5F5F5F;
    }
    .form-control:-moz-placeholder {
       color: #5F5F5F;  
    }
    .form-control::-moz-placeholder { 
       color: #5F5F5F;  
    }
    .form-control:-ms-input-placeholder {  
       color: #5F5F5F;  
    }
    .form-control{
            background: transparent;
    border: 0px;
    border-bottom: 1px solid #5F5F5F !important;
        font-weight: 600;
    }
    input[type="text"]:focus, input[type="text"]:active, input[type="text"]:hover{
        background: transparent;
        font-weight: 900;
    }
    input[type="text"], input[type="password"], select, textarea{
        color: #5F5F5F;
    }
    .login_btn{
        margin-top: 40px;
        border-radius: 0px;
        background: #4B9DD8;
        border: 0px;
        padding: 10px;
        font-weight: 600;
        text-transform: uppercase;
        color: #fff;
    }
    .login_btn:hover, .login_btn:active, .login_btn:focus{
        background: #8DC4EA;
        color: #fff
    }
    .login_otp{
        width: 30%;
        border-radius: 0px;
        background: #5F5F5F;
        border: 0px;
        padding: 10px;
        font-weight: 600;
        text-transform: uppercase;
        color: #FFFFFF;
        font-size: 12px;
    }
    .login_otp:hover, .login_otp:active, .login_otp:focus{
        border:1px solid #5F5F5F;
        color: #5F5F5F;
        padding:9px 10px;
    }
    .alternate_login{
        margin-top: 30px;
    }
 /*   .alternate_login label{
        background: #89ceff;
        padding: 10px 20px;
        border-radius: 2px;
    }*/
    .alternate_login label a{
        color: #4B9DD8;
    }
    .alternate_login label a:hover{
        color:#5B86A5;
    }
    .or_div{
    line-height: 0.5;
    text-align: center;
    width: 100%;
    margin-top: 20px;
    }
    .or_div p{
    display: inline-block;
    position: relative;
    color: #505050;
    font-weight: 600;
    border: 1px solid #505050;
    width: 40px;
    height: 40px;
    line-height: 40px;
    border-radius: 50%;
    }
    .or_div p:before, .or_div p:after{
    content: "";
    position: absolute;
    height: 5px;
    border-bottom: 1px solid #7D7D7D;
    top: 15px;
    width: 130px;
    }
    .or_div p:before{
         right: 100%;
    }
    .or_div p:after{
        left: 100%;
    }
    .alert.alert-danger {
        background: none repeat scroll 0 0 #F95B5B;
        border-color: #F95B5B;
        color: #ffffff;
        border-radius: 0;
        padding: 10px;
    }
    .alert.alert-warning{
        background: none repeat scroll 0 0 #FFA84F;
        border-color: #FFA84F;
        color: #ffffff;
        border-radius: 0;
        padding: 10px;
    }

    
    
    
    
    
    
    
</style>
			
			<div class="layout-app" style="height: 100%;"><!-- row-app -->
<div class="row row-app" style="height: 100%;">

	<!-- col -->
	

		<!-- col-separator.box -->
		<div class="col-separator col-unscrollable box" style="height: 100%;">
			
			<!-- col-table -->
			<div class="col-table blur_bg" style="height: 100%;">
				<!-- col-table-row -->
				<div class="col-table-row" style="height: 100%;">

					<!-- col-app -->
					<div class="col-app col-unscrollable" style="height: 100%;">

						<!-- col-app -->
						<div class="col-app" style="height: 100%;">
							<div class="login col-sm-4 col-sm-offset-4">
                                <div class="login_head">
                                    <img src="custom/logo.png">
                                    <p class="innerAll margin-none text-center hidden-xs">Login to your account</p>
                                </div>
								<div class="panel panel-default col-sm-12">

								  <div class="panel-body">
								  

<div id='alertdiv'>
<?php 
$class="";
$type="";
$msg="";
if(isset($error))
{
  if($error=="activationsuccess"){$class="success";$type="Verified!";$msg="Congratulations, your account is now active, please login to continue.";}
  else if($error=="authfailed"){$class="danger";$type="Login Failed!";$msg="Incorrect Email id or password.";}
  else if($error=="Unverified"){$class="danger";$type="Verification Required!";$msg="We have sent a verification mail to your email id, please follow instructions in the mail.";}
  else if($error=="alreadyverified"){$class="warning";$type="Already Verified!";$msg="You have already verified your account.";}
  else if($error=="msie"){$class="info";$type="Internet Explorer Detected!";$msg="This application doesnot work with MS Internet explorer, please download <a href='http://firefox.com' target=_BLANK>Mozilla Firefox</a> or <a href='http://google.com/chrome' target=_BLANK>Google Chrome</a> to use.";}
  else if($error=="forgotpassword"){$class="info";$type="Password Reminder Sent";$msg="Please check your email for instructions to login to your account. Thankyou";}
  else if($error=="passwordchanged"){$class="success";$type="Password Changed successfully";$msg="You can now login with your new password below!";}
  else if($error=="resetexpired"){$class="danger";$type="Link Expired";$msg="The Link You used is now Expired!";}
  else if($error=="Disabled"){$class="danger";$type="Disabled";$msg="This user account has been disabled, please contact Support!";}
  else {$class="danger";$type="Failed!";$msg="Unknown Error. Method not found";}
  
?>
<!-- Alert -->
<div class="alert alert-{!!$class!!}">
	<button type="button" class="close" data-dismiss="alert">&times;</button>
	<strong>{!!$type!!}</strong> {!!$msg!!}
</div>
<!-- // Alert END -->
<?php } ?>
</div>
								  
								  	<form role="form" action="login" method=post id=owaform>
								  	<input type="hidden" name="_token" value="{{{ csrf_token() }}}" />


								  	  <div class="form-group">
									  <!--  <label for="exampleInputEmail1">Login ID <?php if(Config::get("app.extAuth")=="owa")echo "(Domain Login)"; ?></label> -->
									    <input type="text" class="form-control" id="exampleInputEmail1" name=username placeholder="Login ID">
									  </div>
									  <div class="form-group">
									    <!--  <label for="exampleInputPassword1">Password</label> -->
									    <input type="password" class="form-control" id="exampleInputPassword1" name=password placeholder="Password">
									  </div>

									  <button type="submit" class="btn btn-primary btn-block login_btn">Login</button>
<!-- 									  <button type="button" onclick='document.location="signup";' class="btn btn-primary btn-block">Signup</button> -->
                                       <!-- <div class="or_div"><p>OR</p></div> -->
									  <div class="alternate_login">
									    <label class="pull-left"><a href='#' onclick='$("#owaform").hide();$("#otpform").show();return false;'>Alternate login via OTP</a></label>
									    <label class="pull-right"><a href='mailto:{!!Config::get("app.email")!!}' class='pull-right'>Contact Support</a></label>
									  </div>

									</form>

									
								  	<form role="form" action="login" method=post id=otpform style='display:none'>
								  	<input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
								  	<input type="hidden" name="otplogin" value="true" />
                                        <div class="form-group">
                                            <input type="text" class="form-control" style="width:70%;float: left;margin-top: 3px;" id="exampleInputEmail2" name="username" placeholder="UserName">
                                            <button type="button" class="btn btn-primary btn-block login_otp" onclick='getOTP();return false;'>Get OTP</button>
                                        </div>
									  
									  <div class="form-group">
									   <!-- <label for="exampleInputPassword2">Enter OTP</label>-->
									    <input type="password" class="form-control" id="exampleInputPassword2" name=password placeholder="Enter otp">
									  </div>

									  <button type="submit" class="btn btn-primary btn-block login_btn">Login</button>
<!-- 									  <button type="button" onclick='document.location="signup";' class="btn btn-primary btn-block">Signup</button> -->

									  <div class="alternate_login">
									    <label>
									      <a href='#' onclick='$("#owaform").show();$("#otpform").hide();return false;'>Back to Login</a>
									    </label>
									  </div>

									</form>

									
									
								  </div>
								
								</div>
<!--								<div class="col-sm-2 col-sm-4 col-sm-offset-4 text-center">
									<a href="signup" class="btn btn-info">Create a new account? <i class="fa fa-pencil"></i> </a>
								</div>-->

							
							</div>


						</div>
						<!-- // END col-app -->

					</div>
					<!-- // END col-app.col-unscrollable -->

				</div>
				<!-- // END col-table-row -->
			
			</div>
			<!-- // END col-table -->
			
		</div>
		<!-- // END col-separator.box -->


</div>
<!-- // END row-app -->

<script>
function getOTP()
{
    var username=$("#exampleInputEmail2").val();
    $("#alertdiv").html('<div class="alert alert-warning"><button type="button" class="close" data-dismiss="alert">&times;</button><strong>Please Wait..</strong> Sending OTP for User ('+username+')</div>');
    doAjax('login?sendotp=1&otpuser='+username,'','','ajax_login_otp','singlefail','GET',function(){
        
    });
}
</script>


@include('layout.footer')
<?php 
}
?>