Skip to content

Commit c36272d

Browse files
committed
Add description for modal login dialog
1 parent a717d35 commit c36272d

3 files changed

Lines changed: 56 additions & 19 deletions

File tree

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,41 @@ $(document).on('sign-in', function () {
315315

316316
[![Modal Login Dialog](https://raw.githubusercontent.com/ServiceStack/HttpBenchmarks/master/src/BenchmarksAnalyzer/Content/img/login-modal.png)](https://github.com/ServiceStack/HttpBenchmarks/blob/master/src/BenchmarksAnalyzer/Views/Shared/_Layout.cshtml)
317317

318+
The Login Form popup is another regular Bootstrap Form with `UserName` and `Password` fields as well as `Close` and `Sign-In` buttons to submit the form:
319+
320+
```html
321+
<form id="form-login" action="/auth/credentials">
322+
...
323+
<div class="modal-body">
324+
<p class="error-summary alert alert-danger"></p>
325+
<div class="form-group">
326+
<label>Email:</label>
327+
<input class="form-control" type="text" name="UserName" value=""/>
328+
</div>
329+
<div class="form-group">
330+
<label>Password:</label>
331+
<input class="form-control" type="password" name="Password"/>
332+
</div>
333+
</div>
334+
<div class="modal-footer">
335+
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
336+
<button type="submit" class="btn btn-primary">Sign In</button>
337+
</div>
338+
</form>
339+
```
340+
341+
Just like registration, the login form uses **ss-utils.js** `$.bindForm()` to ajaxify the form and provide automatic form and validation binding. When authentication is successful the `success` callback is invoked which hides the login modal dialog, saves the last UserName in localStorage and triggers a custom `signed-in` event:
342+
343+
```javascript
344+
$("#form-login").bindForm({
345+
success: function (r) {
346+
$('#modalLogin').modal('hide');
347+
localStorage["UserName"] = $("[name=UserName]").val();
348+
$(document).trigger('signed-in');
349+
}
350+
});
351+
```
352+
318353
## Personalized Home Page
319354

320355
Like many popular social websites, the home page changes based on whether the user has signed-in.

src/BenchmarksAnalyzer/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<div class="modal fade" id="modalLogin">
2525
<div class="modal-dialog">
26-
<form id="form-login" action="/auth/login">
26+
<form id="form-login" action="/auth/credentials">
2727
<div class="modal-content">
2828
<div class="modal-header">
2929
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>

src/BenchmarksAnalyzer/Web.config

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<configuration>
99
<configSections>
10-
10+
1111
<section name="glimpse" type="Glimpse.Core.Configuration.Section, Glimpse.Core" />
1212
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false" />
1313
<sectionGroup name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection, DotNetOpenAuth">
@@ -16,13 +16,15 @@
1616
<section name="messaging" type="DotNetOpenAuth.Configuration.MessagingElement, DotNetOpenAuth" requirePermission="false" allowLocation="true" />
1717
<section name="reporting" type="DotNetOpenAuth.Configuration.ReportingElement, DotNetOpenAuth" requirePermission="false" allowLocation="true" />
1818
</sectionGroup>
19-
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor">
19+
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor">
2020
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor" requirePermission="false" />
2121
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor" requirePermission="false" />
22-
</sectionGroup></configSections>
22+
</sectionGroup>
23+
</configSections>
2324

2425
<appSettings>
25-
26+
<add key="webPages:Enabled" value="false" />
27+
2628
<add key="DebugMode" value="True" />
2729

2830
<!-- Auth config -->
@@ -42,7 +44,7 @@
4244
<!-- Create LinkedIn App at: https://www.linkedin.com/secure/developer?newapp= -->
4345
<add key="oauth.LinkedIn.ConsumerKey" value="ck8n5g2fxd6o" />
4446
<add key="oauth.LinkedIn.ConsumerSecret" value="Mpy9Pl4uTnRrSee8" />
45-
<add key="webPages:Enabled" value="false" /></appSettings>
47+
</appSettings>
4648

4749
<system.webServer>
4850
<validation validateIntegratedModeConfiguration="false" />
@@ -60,10 +62,10 @@
6062
<assemblies>
6163
<add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
6264
</assemblies>
63-
64-
<buildProviders>
65+
<buildProviders>
6566
<add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
66-
</buildProviders></compilation>
67+
</buildProviders>
68+
</compilation>
6769
<httpRuntime targetFramework="4.5" />
6870
<httpHandlers>
6971
<!-- IIS6 mapping required for Mono -->
@@ -80,20 +82,20 @@
8082
<system.web.webPages.razor>
8183
<pages pageBaseType="ServiceStack.Razor.ViewPage">
8284
<namespaces>
83-
84-
85-
86-
87-
88-
8985
<add namespace="BenchmarksAnalyzer.ServiceInterface" />
9086
<add namespace="BenchmarksAnalyzer.ServiceModel" />
9187
<add namespace="BenchmarksAnalyzer.ServiceModel.Types" />
92-
93-
<add namespace="System" /><add namespace="ServiceStack" /><add namespace="ServiceStack.Html" /><add namespace="ServiceStack.Razor" /><add namespace="ServiceStack.Text" /><add namespace="ServiceStack.OrmLite" /><add namespace="BenchmarksAnalyzer" /></namespaces>
88+
<add namespace="System" />
89+
<add namespace="ServiceStack" />
90+
<add namespace="ServiceStack.Html" />
91+
<add namespace="ServiceStack.Razor" />
92+
<add namespace="ServiceStack.Text" />
93+
<add namespace="ServiceStack.OrmLite" />
94+
<add namespace="BenchmarksAnalyzer" />
95+
</namespaces>
9496
</pages>
95-
96-
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc" /></system.web.webPages.razor>
97+
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc" />
98+
</system.web.webPages.razor>
9799

98100
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
99101
<!--

0 commit comments

Comments
 (0)