< Summary - Syki

Information
Class: Syki.Back.Features.Identity.SocialLoginChallenge.SocialLoginChallengeController
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Identity/SocialLoginChallenge/SocialLoginChallengeController.cs
Tag: 97_27801654829
Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 39
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
Challenge(...)0%4260%

File(s)

/home/runner/work/syki/syki/Back/Features/Identity/SocialLoginChallenge/SocialLoginChallengeController.cs

#LineLine coverage
 1using Syki.Back.Auth.Schemes;
 2using Microsoft.AspNetCore.Authentication;
 3
 4namespace Syki.Back.Features.Identity.SocialLoginChallenge;
 5
 6[ApiController, EnableRateLimiting(RateLimitingConfigs.SensitivePolicy)]
 07public class SocialLoginChallengeController(FrontendSettings frontendSettings) : ControllerBase
 8{
 9    /// <summary>
 10    /// Social Login Challenge 🔓
 11    /// </summary>
 12    /// <remarks>
 13    /// Redirects to the social login provider (Google) for authentication.
 14    /// This is a browser redirect endpoint, not a JSON API.
 15    /// The optional email parameter sets login_hint for the provider.
 16    /// </remarks>
 17    [HttpGet("identity/social-login/challenge/{provider}")]
 18    public IActionResult Challenge(string provider, [FromQuery] string? email = null)
 19    {
 020        Enum.TryParse(provider, ignoreCase: true, out SocialLoginProvider loginProvider);
 21
 022        var schemeName = loginProvider switch
 023        {
 024            SocialLoginProvider.Google => SocialLoginScheme.GoogleScheme,
 025            _ => null,
 026        };
 27
 028        if (schemeName == null) return Redirect($"{frontendSettings.Url}?social_login_error={nameof(SocialLoginFailed)}"
 29
 030        var properties = new AuthenticationProperties
 031        {
 032            RedirectUri = "/home",
 033        };
 34
 035        if (email != null) properties.Items["login_hint"] = email;
 36
 037        return Challenge(properties, schemeName);
 38    }
 39}