Skip to content

Commit e908c44

Browse files
authored
Merge branch 'master' into reply-like
2 parents 15ddb66 + 182a80a commit e908c44

File tree

9 files changed

+22
-15
lines changed

9 files changed

+22
-15
lines changed

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
APP_ENV=local
22
APP_KEY=
33
APP_DEBUG=true
4-
APP_URL=http://laravelio.app
4+
APP_URL=http://laravelio.test
55

66
DB_DATABASE=homestead
77
DB_USERNAME=homestead
@@ -15,4 +15,4 @@ MAIL_PASSWORD=null
1515

1616
GITHUB_ID=
1717
GITHUB_SECRET=
18-
GITHUB_URL=http://laravelio.app/auth/github
18+
GITHUB_URL=http://laravelio.test/auth/github

Homestead.yaml.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ folders:
1111
to: /home/vagrant/Code/laravelio
1212
sites:
1313
-
14-
map: laravelio.app
14+
map: laravelio.test
1515
to: /home/vagrant/Code/laravelio/public
1616
databases:
1717
- homestead

app/Http/Controllers/Auth/GithubController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Auth;
66
use App\User;
7+
use Laravel\Socialite\Two\InvalidStateException;
78
use Socialite;
89
use App\Social\GithubUser;
910
use App\Jobs\UpdateProfile;
@@ -27,7 +28,13 @@ public function redirectToProvider()
2728
*/
2829
public function handleProviderCallback()
2930
{
30-
$socialiteUser = Socialite::driver('github')->user();
31+
try {
32+
$socialiteUser = Socialite::driver('github')->user();
33+
} catch (InvalidStateException $exception) {
34+
$this->error('errors.github_invalid_state');
35+
36+
return redirect()->route('login');
37+
}
3138

3239
try {
3340
$user = User::findByGithubId($socialiteUser->getId());

database/factories/ReplyFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
use App\Models\Reply;
55
use App\Models\Thread;
66

7-
$factory->define(Reply::class, function (Faker\Generator $faker) {
7+
$factory->define(Reply::class, function (Faker\Generator $faker, array $attributes = []) {
88
return [
99
'body' => $faker->text(),
10-
'author_id' => factory(User::class)->create()->id(),
11-
'replyable_id' => factory(Thread::class)->create()->id(),
10+
'author_id' => $attributes['author_id'] ?? factory(User::class)->create()->id(),
11+
'replyable_id' => $attributes['replyable_id'] ?? factory(Thread::class)->create()->id(),
1212
'replyable_type' => Thread::TABLE,
1313
'ip' => $faker->ipv4,
1414
];

database/factories/ThreadFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
use App\User;
44
use App\Models\Thread;
55

6-
$factory->define(Thread::class, function (Faker\Generator $faker) {
6+
$factory->define(Thread::class, function (Faker\Generator $faker, array $attributes = []) {
77
return [
88
'subject' => $faker->text(20),
99
'body' => $faker->text,
1010
'slug' => $faker->slug,
11-
'author_id' => factory(User::class)->create()->id(),
11+
'author_id' => $attributes['author_id'] ?? factory(User::class)->create()->id(),
1212
'ip' => $faker->ipv4,
1313
];
1414
});

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<env name="CACHE_DRIVER" value="array"/>
2828
<env name="DB_CONNECTION" value="sqlite"/>
2929
<env name="DB_DATABASE" value=":memory:"/>
30-
<env name="MAIL_DRIVER" value="log"/>
30+
<env name="MAIL_DRIVER" value="array"/>
3131
<env name="SESSION_DRIVER" value="array"/>
3232
<env name="QUEUE_DRIVER" value="sync"/>
3333
</php>

readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@ The following tools are required in order to start the installation.
3737
2. Run `composer start`
3838
4. Run `vagrant up`
3939
5. SSH into your Vagrant box, go to `/home/vagrant/Code/laravelio` and run `composer setup`
40-
6. Add `192.168.10.10 laravelio.app` to your computer's `/etc/hosts` file
40+
6. Add `192.168.10.10 laravelio.test` to your computer's `/etc/hosts` file
4141
7. Setup a working e-mail driver like [Mailtrap](https://mailtrap.io/)
4242
8. (optional) Set up Github authentication (see below)
4343

44-
You can now visit the app in your browser by visiting [http://laravelio.app](http://laravelio.app). If you seeded the database you can login into a test account with `johndoe` & `password`.
44+
You can now visit the app in your browser by visiting [http://laravelio.test](http://laravelio.test). If you seeded the database you can login into a test account with `johndoe` & `password`.
4545

4646
### Github Authentication (optional)
4747

48-
To get Github authentication to work locally, you'll need to [register a new OAuth application on Github](https://github.com/settings/applications/new). Use `http://lio.app` for the homepage url and `http://lio.app/auth/github` for the callback url. When you've created the app, fill in the ID and secret in your `.env` file in the env variables below. You should now be able to authentication with Github.
48+
To get Github authentication to work locally, you'll need to [register a new OAuth application on Github](https://github.com/settings/applications/new). Use `http://laravelio.test` for the homepage url and `http://laravelio.test/auth/github` for the callback url. When you've created the app, fill in the ID and secret in your `.env` file in the env variables below. You should now be able to authentication with Github.
4949

5050
```
5151
GITHUB_ID=
5252
GITHUB_SECRET=
53-
GITHUB_URL=http://laravelio.app/auth/github
53+
GITHUB_URL=http://laravelio.test/auth/github
5454
```
5555

5656
## Maintainers

resources/lang/en/errors.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'banned' => 'This account is banned.',
66
'fields' => 'Something went wrong. Please review the fields below.',
77
'unconfirmed' => '<a href="'.route('email.send_confirmation').'" class="alert-link">Please confirm your email address first.</a>',
8+
'github_invalid_state' => 'The request timed out. Please try again.',
89
'github_account_too_young' => 'Your Github account needs to be older than 2 weeks in order to register.',
910

1011
];

routes/web.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
// Registration
1616
Route::get('register', ['as' => 'register', 'uses' => 'RegisterController@showRegistrationForm']);
17-
Route::get('signup', 'RegisterController@redirectToRegistrationForm'); // BC for old links
1817
Route::post('register', ['as' => 'register.post', 'uses' => 'RegisterController@register']);
1918

2019
// Password reset

0 commit comments

Comments
 (0)