Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,14 @@ PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"


facebook_CLIENT_ID =
facebook_CLIENT_SECRET =

google_CLIENT_ID =
google_CLIENT_SECRET =


twitter_CLIENT_ID =
twitter_CLIENT_SECRET =
82 changes: 53 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,75 @@
# Back-end developer exercise

© 2018 Renderbit Technologies LLP.
I am Joy Dey.

## Prerequisites
## Use
I did use

You should be familiar with PHP 7, Laravel 5, Git and GitHub.
1. PHP
2. Apache server
3. MySQL Database
4. VS CODE

## Getting Started

This tutorial assumes you have a PHP 7 development environment set up on your machine, with the following components at minimum:
### Extra

1. PHP 7.1 or better
2. Choice of server (Apache/Nginx)
3. Choice of Database (MySQL/MariaDB/PostgreSQL/SQLite)
4. Choice of IDE/Editor
- social login feature which allows users to login and sign up via their Google+/Facebook/Twitter/Github accounts.
- Allow photos to be inserted into blog posts.
- Allow ckeditor editing of blog posts with rich formatting support.

Fork this repository, and clone your fork locally. All submissions have to be made as a pull request against this repository.

## Requirements
### Link

You have to design a blogging application.
- Home page link: ```<sitename>```
- About page link: ```<sitename>/<about>```
- Admin page link: ```<sitename>/<admin>```
- One User All Post Link: ```<sitename>/<profile>/<username>```
- One Single Post Link: ```<sitename>/<profile>/<username>/<Post_id>```
And I use Link verification.




### Configuration for social login

Any user can sign up and create a blog of their own. When signing up, you have to record the user's full name, unique email address, password (8 characters minimum with 1 special character required) and choice of unique username.
For social login feature, we must configure .env
[Socialite](https://laravel.com/docs/6.x/socialite)

The homepage of the blog can be viewed by anyone without login. The homepage shall show a list of all blog posts by all users, with most recent posts on top. The list of blog posts shall be paginated, with 8 posts per page. On clicking a post, a user can view the entire post content.

Every user shall have his/her blog home page at `<sitename>/<username>`. This page shall show a list of all posts by the particular user, with most recent posts on top. This list of blog posts shall also be paginated, with 8 posts per page. On clicking a post, a user can view the entire post content.
```
facebook_CLIENT_ID =
facebook_CLIENT_SECRET =

A blog post has the URL `<sitename>/<username>/<post_unique_slug_from_title>`. A blog post has a post title and post content. Anyone can view a blog post without login. However, you need to login to comment on a blog post. Any user can comment on any blog post. However, a user can only delete comments that he has made on other users' blog posts. The author of the blog post can delete any comment on the blog post made by any user. The comments are shown below the blog post content, with most recent comments on top. A form to add a new comment is shown above the comments thread.
google_CLIENT_ID =
google_CLIENT_SECRET =

Every user can access the admin panel at `<sitename>/admin`. A user has to login to access the admin panel. The admin panel should show a list of all posts, with an option to edit and delete each post. The admin panel should also have an option to create a new post.

### UI
twitter_CLIENT_ID =
twitter_CLIENT_SECRET =

You are free to use any UI framework or library of your choice. We recommend [Bootstrap](https://getbootstrap.com) as a good place to get started.
```

Note that you are not required to build a mobile responsive website, although if you build one, we will be assigning extra credits for that.

### Libraries & Frameworks
### Configuration for CKeditor [CKeditor](https://github.com/UniSharp/laravel-ckeditor)

You are free to use any libraries, frameworks & tools which you think will be useful to build this application. No credits are deducted for use of libraries.
```
composer require unisharp/laravel-ckeditor
```

### Extra Credits

- Implement a social login feature which allows users to login and sign up via their Google+/Facebook/Twitter/Github accounts.
- Allow photos to be inserted into blog posts.
- Allow WYSIWYG editing of blog posts with rich formatting support.
- Implement a CAPTCHA for adding comments.
- Implement two-factor authentication for login using SMS for one-time passwords.
- Surprise us. :smiley:
### Configuration for Storage

I use Storage link command for Storage sortcut

```
php artisan storage:link

```


### Configuration for Database

```
php artisan migrate

```
60 changes: 59 additions & 1 deletion app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Socialite;
use App\user;
use Illuminate\Support\Facades\Auth;


class LoginController extends Controller
{
Expand All @@ -25,7 +29,7 @@ class LoginController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = '/admin';

/**
* Create a new controller instance.
Expand All @@ -36,4 +40,58 @@ public function __construct()
{
$this->middleware('guest')->except('logout');
}


/**
* Redirect the user to the facebook authentication page.
*
* @return \Illuminate\Http\Response
*/
public function redirectToProvider($service)
{
return Socialite::driver($service)->redirect();
}

/**
* Obtain the user information from facebook.
*
* @return \Illuminate\Http\Response
*/
public function handleProviderCallback($service)
{
if($service == 'twitter'){

$socialuser = Socialite::driver($service)->user();

} else{

$socialuser = Socialite::driver($service)->stateless()->user();

}


//find user
$finduser = User::where('email', $socialuser->email)->first();

if($finduser){

Auth::login($finduser);

}
else{

$user = new User;
$user->name = $socialuser->name;
$user->u_name = $socialuser->name.$socialuser->id;
$user->email = $socialuser->email;
$user->password = bcrypt(123456789);
$user->save();
Auth::login($user);

}

}



}
13 changes: 11 additions & 2 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class RegisterController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = '/admin';

/**
* Create a new controller instance.
Expand All @@ -40,6 +40,9 @@ public function __construct()
$this->middleware('guest');
}




/**
* Get a validator for an incoming registration request.
*
Expand All @@ -50,8 +53,12 @@ protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'u_name' => 'required|string|max:255|unique:users',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
'address' => 'required|string|max:2000',
'password' => 'required|string|min:8|confirmed|regex:/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{6,}$/',

//
]);
}

Expand All @@ -65,7 +72,9 @@ protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'u_name' => $data['u_name'],
'email' => $data['email'],
'address' => $data['address'],
'password' => Hash::make($data['password']),
]);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/ResetPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ResetPasswordController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = '/admin';

/**
* Create a new controller instance.
Expand Down
42 changes: 42 additions & 0 deletions app/Http/Controllers/PagesController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\post;
use App\User;
use Illuminate\Support\Str;

class PagesController extends Controller
{
//index page
public function index()
{
$posts = Post::orderBy('id', 'desc')->paginate(8);
return view('pages.index')->with('posts', $posts);

}
//about page
public function about()
{
return view('pages.about');
}

//user page
public function urname($uname)
{
//find user
$finduser = User::where('u_name', '=', $uname)->first();
if(!$finduser){
return redirect('/')->with('error' , "Sorry We Can not find any user by this name");
}else{

$posts = Post::where('user_id', '=', $finduser->id)->orderBy('id', 'desc')->paginate(8);
return view('pages.profile')->with(compact('posts', 'finduser'));

}
}



}
Loading