Skip to content

Commit

Permalink
Merge pull request #2 from danivideda/master
Browse files Browse the repository at this point in the history
Update my repo from remote
  • Loading branch information
FX24 authored Dec 1, 2020
2 parents f9857aa + bcb90a7 commit d4d8def
Show file tree
Hide file tree
Showing 42 changed files with 890 additions and 288 deletions.
23 changes: 21 additions & 2 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class LoginController extends Controller
{
Expand All @@ -16,11 +17,29 @@ public function showTeacherLoginForm() {
}

public function loginStudent(Request $request) {
//
$this->validate($request, [
'email' => 'required|email',
'password' => 'required'
]);

if (!Auth::guard('student')->attempt($request->only('email', 'password'))) {
return back()->with('status', 'Invalid login details');
}

return redirect()->route('student.dashboard');
}

public function loginTeacher(Request $request) {
//
$this->validate($request, [
'email' => 'required|email',
'password' => 'required'
]);

if (!Auth::guard('teacher')->attempt($request->only('email', 'password'))) {
return back()->with('status', 'Invalid login details');
}

return redirect()->route('teacher.dashboard');
}

}
22 changes: 22 additions & 0 deletions app/Http/Controllers/Auth/LogoutController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class LogoutController extends Controller
{
public function logoutStudent() {
Auth::guard('student')->logout();

return redirect()->route('home');
}

public function logoutTeacher() {
Auth::guard('teacher')->logout();

return redirect()->route('home');
}
}
4 changes: 4 additions & 0 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ public function showTeacherRegisterForm() {
public function registerStudent(Request $request) {
$this->validate($request, [
'name' => 'required|max:255',
'nickname' => 'required|max:255',
'email' => 'required|email|unique:students|max:255',
'password' => 'required|confirmed',
]);

Student::create([
'name' => $request->name,
'nickname' => $request->nickname,
'email' => $request->email,
'password' => Hash::make($request->password)
]);
Expand All @@ -40,13 +42,15 @@ public function registerStudent(Request $request) {
public function registerTeacher(Request $request) {
$this->validate($request, [
'name' => 'required|max:255',
'nickname' => 'required|max:255',
'school_name' => 'required|max:255',
'email' => 'required|email|unique:teachers|max:255',
'password' => 'required|confirmed',
]);

Teacher::create([
'name' => $request->name,
'nickname' => $request->nickname,
'school_name' => $request->school_name,
'email' => $request->email,
'password' => Hash::make($request->password)
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/StudentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
class StudentController extends Controller
{
public function index() {
return view('student.dashboard');
return view('student.home.dashboard');
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/TeacherController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
class TeacherController extends Controller
{
public function index() {
return view('teacher.dashboard');
return view('teacher.home.dashboard');
}
}
3 changes: 3 additions & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ class Kernel extends HttpKernel
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.student' => \App\Http\Middleware\Student::class,
'auth.teacher' => \App\Http\Middleware\Teacher::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'guest.custom' => \App\Http\Middleware\RedirectIfAuthenticatedAsStudentOrTeacher::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
Expand Down
27 changes: 27 additions & 0 deletions app/Http/Middleware/RedirectIfAuthenticatedAsStudentOrTeacher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class RedirectIfAuthenticatedAsStudentOrTeacher
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if (auth()->guard('student')->check()) {
return redirect()->route('student.dashboard');
} else if (auth()->guard('teacher')->check()) {
return redirect()->route('teacher.dashboard');
} else {
return $next($request);
}
}
}
25 changes: 25 additions & 0 deletions app/Http/Middleware/Student.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class Student
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if (auth()->guard('student')->check()) {
return $next($request);
}

return redirect()->route('login.student');
}
}
25 changes: 25 additions & 0 deletions app/Http/Middleware/Teacher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class Teacher
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if (auth()->guard('teacher')->check()) {
return $next($request);
}

return redirect()->route('login.student');
}
}
1 change: 1 addition & 0 deletions app/Models/Student.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Student extends Authenticatable

protected $fillable = [
'name',
'nickname',
'email',
'password'
];
Expand Down
1 change: 1 addition & 0 deletions app/Models/Teacher.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Teacher extends Authenticatable

protected $fillable = [
'name',
'nickname',
'school_name',
'email',
'password'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function up()
Schema::create('students', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('nickname');
$table->string('email')->unique();
$table->json('classroom_joined')->nullable();
$table->timestamp('email_verified_at')->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function up()
Schema::create('teachers', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('nickname');
$table->string('school_name');
$table->string('email')->unique();
$table->json('classroom_teached')->nullable();
Expand Down
4 changes: 4 additions & 0 deletions public/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -31168,6 +31168,10 @@ video {
animation: bounce 1s infinite;
}

.text-underline-custom {
border-bottom: 5px rgba(223, 77, 102, 1) solid;
}

@media (min-width: 640px) {
.sm\:container {
width: 100%;
Expand Down
Binary file added public/img/landing-illustration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/student-illustration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/img/teacher-illustration.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions resources/css/app.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

.text-underline-custom {
border-bottom: 5px rgba(223, 77, 102, 1) solid;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,28 @@
<section class="bg-gradient-to-r from-blue-300 to-green-400 pt-12 pb-16 md:pt-8 px-8 h-screen" id="login">
<div class="container mx-auto flex flex-wrap flex-col md:flex-row items-center px-10">
<div class="w-full xl:w-7/12 py-6 overflow-y-hidden">
<img class="w-5/6 lg:mr-0" src="http://www.pngall.com/wp-content/uploads/5/Learning-PNG-Free-Download.png">
<img class="w-5/6 lg:mr-0" src="{{ asset('img/student-illustration.png') }}">
</div>
<div class="flex flex-col w-full xl:w-5/12 justify-center overflow-y-hidden">
<div class="bg-blue-500 px-4 py-8">
<span class="text-black font-extrabold text-center text-3xl inline mx-9"> LOGIN </span>
<p class="text-black font-extrabold text-center text-3xl inline mx-9 "> | </p>
<a class="text-gray-600 font-extrabold text-center text-3xl inline mx-9" href="{{ route('register.student') }}"> SIGN UP </a>
<div class="bg-blue-500 px-4 py-8 flex gap-2">
<span class="text-black font-extrabold text-center text-3xl inline mx-auto text-underline-custom"> LOGIN </span>
<p class="text-black font-extrabold text-center text-3xl inline mx-auto"> | </p>
<a class="text-gray-600 font-extrabold text-center text-3xl inline mx-auto" href="{{ route('register.student') }}"> SIGN UP </a>
</div>
<div class="bg-white py-16 px-20">
<form action="" method="post">
<div class="bg-white pb-16 pt-5 px-20">
<div>
<p class="pt-2 text-black">Currently logging in as <span class="font-bold text-black">Student</span>.</p>
<p class="pb-4 text-gray-500 text-sm"> or login as Teacher <a class="underline" href="{{route('login.teacher')}}">here</a></p>
@if (session('status'))
<div class="bg-red-400 p-4 rounded-lg mb-6 text-white text-center">
{{ session('status') }}
</div>
@endif
</div>
<form action="{{ route('login.student') }}" method="POST">
@csrf
<div class="mb-4">
<label for="email" class="sr-only">Email</label>
<label for="email" class="uppercase tracking-wide text-gray text-xs font-bold">Email</label>
<input type="text" name="email" id="email" placeholder="Email"
class="bg-gray-100 border-2 w-full p-4 rounded-lg @error('email') border-red-500 @enderror" value="{{ old('email') }}">

Expand All @@ -29,7 +38,7 @@ class="bg-gray-100 border-2 w-full p-4 rounded-lg @error('email') border-red-500
</div>

<div class="mb-4">
<label for="password" class="sr-only">Password</label>
<label for="password" class="uppercase tracking-wide text-gray text-xs font-bold">Password</label>
<input type="password" name="password" id="password" placeholder="Password"
class="bg-gray-100 border-2 w-full p-4 rounded-lg @error('password') border-red-500 @enderror" value="">

Expand Down
60 changes: 60 additions & 0 deletions resources/views/auth/login-teacher.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
@extends('layouts.app')

@section('content')

<section class="bg-gradient-to-r from-blue-300 to-green-400 pt-12 pb-16 md:pt-8 px-8 h-screen" id="login">
<div class="container mx-auto flex flex-wrap flex-col md:flex-row items-center px-10">
<div class="w-full xl:w-7/12 py-6 overflow-y-hidden">
<img class="w-5/6 lg:mr-0" src="{{ asset('img/teacher-illustration.svg') }}">
</div>
<div class="flex flex-col w-full xl:w-5/12 justify-center overflow-y-hidden">
<div class="bg-blue-500 px-4 py-8 flex gap-2">
<span class="text-black font-extrabold text-center text-3xl inline mx-auto text-underline-custom"> LOGIN </span>
<p class="text-black font-extrabold text-center text-3xl inline mx-auto"> | </p>
<a class="text-gray-600 font-extrabold text-center text-3xl inline mx-auto" href="{{ route('register.teacher') }}"> SIGN UP </a>
</div>
<div class="bg-white pb-16 pt-5 px-20">
<div>
<p class="pt-2 text-black">Currently logging in as <span class="font-bold text-black">Teacher</span>.</p>
<p class="pb-4 text-gray-500 text-sm"> or login as Student <a class="underline" href="{{route('login.student')}}">here</a></p>
@if (session('status'))
<div class="bg-red-400 p-4 rounded-lg mb-6 text-white text-center">
{{ session('status') }}
</div>
@endif
</div>
<form action="{{ route('login.teacher') }}" method="POST">
@csrf
<div class="mb-4">
<label for="email" class="uppercase tracking-wide text-gray text-xs font-bold">Email</label>
<input type="text" name="email" id="email" placeholder="Email"
class="bg-gray-100 border-2 w-full p-4 rounded-lg @error('email') border-red-500 @enderror" value="{{ old('email') }}">

@error('email')
<div class="text-red-500 mt-2 text-sm">
{{ $message }}
</div>
@enderror
</div>

<div class="mb-4">
<label for="password" class="uppercase tracking-wide text-gray text-xs font-bold">Password</label>
<input type="password" name="password" id="password" placeholder="Password"
class="bg-gray-100 border-2 w-full p-4 rounded-lg @error('password') border-red-500 @enderror" value="">

@error('password')
<div class="text-red-500 mt-2 text-sm">
{{ $message }}
</div>
@enderror
</div>
<div>
<button type="submit" class="bg-pink-600 text-white px-4 py-3 rounded font-medium w-full">Login</button>
</div>
</form>
</div>
</div>
</div>
</section>

@endsection
Loading

0 comments on commit d4d8def

Please sign in to comment.