Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
forgot password
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwini0529 committed Sep 2, 2016
1 parent e54e907 commit c9e3fdf
Show file tree
Hide file tree
Showing 11 changed files with 416 additions and 214 deletions.
436 changes: 229 additions & 207 deletions .idea/workspace.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function create(array $data)
/*
* Need to send after the user create transaction is done
* */
app('App\Http\Controllers\UserController')->send($data['contact']);
app('App\Http\Controllers\UserController')->send($data['contact'],"Thank You for registering! Start solving problems according to your domain. All the best.");
return User::create([
'name' => $data['name'],
'email' => $data['email'],
Expand Down
29 changes: 29 additions & 0 deletions app/Http/Controllers/Auth/PasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\User;
use Illuminate\Http\Request;

use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Support\Facades\Password;

class PasswordController extends Controller
{
Expand All @@ -29,4 +33,29 @@ public function __construct()
{
$this->middleware('guest');
}

public function sendResetToken(Request $request)
{

$user = User::where('contact',$request->get('contact'))->first();
if($user!=[]) {
$token = rand(100000, 999999);
$message = "Your activation code is : " . $token;
app('App\Http\Controllers\UserController')->send($user->contact, $message);
$password = new \App\Password();
$password->user_id = $user->id;
$password->activation_code = $token;
$password->save();
return view('User.verifyToken');
}
else{
return view('errors.404');
}
}

public function forgotPasswordPage()
{
return view('User.forgotPassword');

}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function getShortlistedCandidates(Request $request)
return view('User.Admin.getShortlistedCandidates',compact('people'));

}
public function send($contactNumber)
public function send($contactNumber, $message)
{
//Your authentication key
$authKey = env('MSG_API_KEY');
Expand All @@ -271,7 +271,7 @@ public function send($contactNumber)
$senderId = "GDGVIT";

//Your message to send, Add URL encoding here.
$message = urlencode("Thank You for registering! You'll be notified when our portal will be live.");
$message = urlencode($message);

//Define route
$route = "transactional";
Expand Down
3 changes: 2 additions & 1 deletion app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
});

Route::auth();

Route::get('/forgot/password','Auth\PasswordController@forgotPasswordPage');
Route::post('/send/token','Auth\PasswordController@sendResetToken');
Route::get('/home', 'HomeController@index');

/*
Expand Down
29 changes: 29 additions & 0 deletions app/Password.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Password extends Model
{

/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'user_id',
'activation_code',
'status'

];


public function User()
{
return $this->belongsTo('App\User');
}


}
4 changes: 4 additions & 0 deletions app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ public function problemStatements()
{
return $this->hasMany('App\ProblemStatement');
}
public function password()
{
return $this->belongsTo('App\Password');
}
}
6 changes: 3 additions & 3 deletions config/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
|
*/

'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),

/*
|--------------------------------------------------------------------------
Expand All @@ -42,7 +42,7 @@
|
*/

'port' => env('MAIL_PORT', 587),
'port' => env('MAIL_PORT', 465),

/*
|--------------------------------------------------------------------------
Expand All @@ -55,7 +55,7 @@
|
*/

'from' => ['address' => null, 'name' => null],
'from' => ['address' => "[email protected]", 'name' => "GDG VIT"],

/*
|--------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateForgotPasswordTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('passwords', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->integer('user_id')->unique();
$table->integer('activation_code');
$table->integer('status')->default(0);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('passwords');
}
}
42 changes: 42 additions & 0 deletions resources/views/User/forgotPassword.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@extends('layouts.app')
<link rel="stylesheet" href="{{url('css/problems.css')}}">


@section('content')
<div class="container">
<div class="row">
<form name="#" id="award-form" method="POST" action="{{ url('/send/token') }}">
{{ csrf_field() }}
<div class="col m8 l8 push-l2 push-l2">
<div class="row">
<div class="col m12 l12">
<div class="data-card">
<div class="card-head">
<h3>Forgot Password</h3>
</div>
<div class="card-body">
<div class="row">
<div class="col m4 l4 s12">
<div class="prob-field form-group{{ $errors->has('contact') ? ' has-error' : '' }}">
<h5> Enter the contact number associated with your account</h5>
</div>
</div>
<div class="col m6 l6 s12">
<div class="input-field form-group{{ $errors->has('contact') ? ' has-error' : '' }}">
<input type="text" name="contact">
</div>
</div>

<button type = "submit" class="btn btn-primary">Get reset token</button>
</div>
</div>

</div>
<br>
</div>
</div>
</div>
</form>
</div>
</div>
@endsection
42 changes: 42 additions & 0 deletions resources/views/User/verifyToken.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@extends('layouts.app')
<link rel="stylesheet" href="{{url('css/problems.css')}}">


@section('content')
<div class="container">
<div class="row">
<form name="#" id="award-form" method="POST" action="{{ url('/send/token') }}">
{{ csrf_field() }}
<div class="col m8 l8 push-l2 push-l2">
<div class="row">
<div class="col m12 l12">
<div class="data-card">
<div class="card-head">
<h3>Verify Token</h3>
</div>
<div class="card-body">
<div class="row">
<div class="col m4 l4 s12">
<div class="prob-field form-group{{ $errors->has('token') ? ' has-error' : '' }}">
<h5> Enter Token</h5>
</div>
</div>
<div class="col m6 l6 s12">
<div class="input-field form-group{{ $errors->has('token') ? ' has-error' : '' }}">
<input type="text" name="token">
</div>
</div>
<button type = "submit" class="btn btn-primary">Verify Token</button>
</div>
</div>
</div>
<br>
</div>
</div>
</div>
</form>
</div>
</div>
@endsection

0 comments on commit c9e3fdf

Please sign in to comment.