Skip to content

Commit

Permalink
removed the need to authorize for connect example (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
annahileta authored Nov 28, 2023
1 parent 79b2882 commit f43451b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 30 deletions.
4 changes: 4 additions & 0 deletions launcher-csharp/Common/RequestItemsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ public string IdentifyApiOfCodeExample(string eg)
{
currentApiType = ExamplesApiType.Admin.ToString();
}
else if (eg.Contains(ExamplesApiType.Connect.ToKeywordString()))
{
currentApiType = ExamplesApiType.Connect.ToString();
}
else
{
currentApiType = ExamplesApiType.ESignature.ToString();
Expand Down
71 changes: 41 additions & 30 deletions launcher-csharp/eSignature/Controllers/EgController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,51 +32,62 @@ public EgController(DsConfiguration config, LauncherTexts launcherTexts, IReques

protected IRequestItemsService RequestItemsService { get; }

public bool CheckIfAuthorizationIsNeeded()
{
bool tokenOk = this.CheckToken();
ExamplesApiType previousLoginSchema = Enum.Parse<ExamplesApiType>(this.RequestItemsService.Configuration["API"]);
ExamplesApiType currentApi = Enum.Parse<ExamplesApiType>(this.RequestItemsService.IdentifyApiOfCodeExample(this.EgName));
this.RequestItemsService.Configuration["APIPlanned"] = currentApi.ToString();

if (currentApi == ExamplesApiType.Connect)
{
return false;
}

if (tokenOk && previousLoginSchema == currentApi)
{
return false;
}

return true;
}

[HttpGet]
public virtual IActionResult Get()
{
// Check that the token is valid and will remain valid for awhile to enable the
// user to fill out the form. If the token is not available, now is the time
// to have the user authenticate or re-authenticate.
bool tokenOk = this.CheckToken();
if (this.RequestItemsService.Configuration["API"] == null)
{
this.RequestItemsService.Configuration["API"] = ExamplesApiType.ESignature.ToString();
}

ExamplesApiType previousLoginSchema = Enum.Parse<ExamplesApiType>(this.RequestItemsService.Configuration["API"]);
ExamplesApiType currentApi = Enum.Parse<ExamplesApiType>(this.RequestItemsService.IdentifyApiOfCodeExample(this.EgName));
this.RequestItemsService.Configuration["APIPlanned"] = currentApi.ToString();

if (tokenOk)
if (this.CheckIfAuthorizationIsNeeded())
{
if (previousLoginSchema == currentApi)
{
// addSpecialAttributes(model);
this.ViewBag.envelopeOk = this.RequestItemsService.EnvelopeId != null;
this.ViewBag.documentsOk = this.RequestItemsService.EnvelopeDocuments != null;
this.ViewBag.documentOptions = this.RequestItemsService.EnvelopeDocuments?.Documents;
this.ViewBag.gatewayOk = this.Config.GatewayAccountId != null && this.Config.GatewayAccountId.Length > 25;
this.ViewBag.templateOk = this.RequestItemsService.TemplateId != null;
this.ViewBag.source = this.CreateSourcePath();
this.ViewBag.documentation = this.Config.Documentation + this.EgName;
this.ViewBag.showDoc = this.Config.Documentation != null;
this.ViewBag.pausedEnvelopeOk = this.RequestItemsService.PausedEnvelopeId != null;
this.InitializeInternal();

if (this.Config.QuickAcg == "true" && !(this is EmbeddedSigningCeremony))
{
return this.Redirect("eg001");
}

return this.View(this.EgName, this);
}
this.RequestItemsService.EgName = this.EgName;
this.Response.Redirect("/ds/mustAuthenticate");

return this.LocalRedirect("/ds/mustAuthenticate");
}

this.RequestItemsService.EgName = this.EgName;
this.Response.Redirect("/ds/mustAuthenticate");
this.ViewBag.envelopeOk = this.RequestItemsService.EnvelopeId != null;
this.ViewBag.documentsOk = this.RequestItemsService.EnvelopeDocuments != null;
this.ViewBag.documentOptions = this.RequestItemsService.EnvelopeDocuments?.Documents;
this.ViewBag.gatewayOk = this.Config.GatewayAccountId != null && this.Config.GatewayAccountId.Length > 25;
this.ViewBag.templateOk = this.RequestItemsService.TemplateId != null;
this.ViewBag.source = this.CreateSourcePath();
this.ViewBag.documentation = this.Config.Documentation + this.EgName;
this.ViewBag.showDoc = this.Config.Documentation != null;
this.ViewBag.pausedEnvelopeOk = this.RequestItemsService.PausedEnvelopeId != null;
this.InitializeInternal();

if (this.Config.QuickAcg == "true" && !(this is EmbeddedSigningCeremony))
{
return this.Redirect("eg001");
}

return this.LocalRedirect("/ds/mustAuthenticate");
return this.View(this.EgName, this);
}

public dynamic CreateSourcePath()
Expand Down

0 comments on commit f43451b

Please sign in to comment.