• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daycry / auth / 26937880755

04 Jun 2026 07:38AM UTC coverage: 75.983% (+4.4%) from 71.569%
26937880755

push

github

web-flow
Merge pull request #56 from daycry/development

feat

613 of 719 new or added lines in 42 files covered. (85.26%)

3 existing lines in 3 files now uncovered.

5179 of 6816 relevant lines covered (75.98%)

69.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

17.39
/src/Controllers/OauthController.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of Daycry Auth.
7
 *
8
 * (c) Daycry <daycry9@proton.me>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace Daycry\Auth\Controllers;
15

16
use Daycry\Auth\Config\AuthOAuth;
17
use Daycry\Auth\Libraries\Oauth\OauthManager;
18
use Exception;
19

20
class OauthController extends BaseAuthController
21
{
22
    protected $helpers = ['setting', 'url'];
23

24
    /**
25
     * Get rules for validation
26
     */
27
    protected function getValidationRules(): array
×
28
    {
29
        return [];
×
30
    }
31

32
    public function redirect(string $provider)
1✔
33
    {
34
        /** @var AuthOAuth $config */
35
        $config  = config('AuthOAuth');
1✔
36
        $manager = new OauthManager($config);
1✔
37

38
        return $manager->setProvider($provider)->redirect();
1✔
39
    }
40

41
    /**
42
     * Begins linking an OAuth provider to the *currently authenticated* user.
43
     *
44
     * Unlike redirect()/callback() (which sign a user in), this stashes the
45
     * logged-in user's id so the shared callback links the provider to them
46
     * explicitly — the safe alternative to merging accounts by e-mail.
47
     */
NEW
48
    public function link(string $provider)
×
49
    {
NEW
50
        if (! auth()->loggedIn()) {
×
NEW
51
            return redirect()->to(config('Auth')->loginPage());
×
52
        }
53

NEW
54
        session()->set('oauth_link_user_id', auth()->id());
×
55

56
        /** @var AuthOAuth $config */
NEW
57
        $config  = config('AuthOAuth');
×
NEW
58
        $manager = new OauthManager($config);
×
59

NEW
60
        return $manager->setProvider($provider)->redirect();
×
61
    }
62

UNCOV
63
    public function callback(string $provider)
×
64
    {
65
        /** @var AuthOAuth $config */
66
        $config  = config('AuthOAuth');
×
67
        $manager = new OauthManager($config);
×
68

69
        try {
70
            $user = $manager->setProvider($provider)->handleCallback(
×
71
                $this->request->getGet('code') ?? '',
×
72
                $this->request->getGet('state') ?? '',
×
73
            );
×
74

75
            return redirect()->to(config('Auth')->loginRedirect());
×
76
        } catch (Exception $e) {
×
77
            return redirect()->to(config('Auth')->loginPage())->with('error', $e->getMessage());
×
78
        }
79
    }
80
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc