Last active
December 22, 2016 16:55
-
-
Save KevM/5547830 to your computer and use it in GitHub Desktop.
FubuContinuations do not redirect when a simple checkbox is present on the input model?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class get_handler | |
{ | |
public SignInModel Execute(SignInRequest request) | |
{ | |
return new SignInModel {ReturnUrl = request.ReturnUrl, LoginFailed = request.LoginFailed}; | |
} | |
} | |
public class post_handler | |
{ | |
private readonly IAuthenticationService _authenticationService; | |
private readonly IUrlRegistry _urlRegistry; | |
public post_handler(IAuthenticationService authenticationService, IUrlRegistry urlRegistry) | |
{ | |
_authenticationService = authenticationService; | |
_urlRegistry = urlRegistry; | |
} | |
public FubuContinuation Execute(SignInModel model) | |
{ | |
var loggedin = _authenticationService.SignIn(model.UserName, model.Password, true); | |
if (loggedin) | |
{ | |
return FubuContinuation.RedirectTo(model.ReturnUrl.IsEmpty() ? _urlRegistry.UrlFor<HomeRequest>() : model.ReturnUrl); | |
} | |
return FubuContinuation.TransferTo(new SignInRequest { ReturnUrl = model.ReturnUrl, LoginFailed = true }); | |
} | |
} | |
public class SignInRequest | |
{ | |
[QueryString] | |
public string ReturnUrl { get; set; } | |
[QueryString] | |
public bool LoginFailed { get; set; } | |
} | |
public class SignInModel | |
{ | |
public SignInModel() | |
{ | |
ReturnUrl = ""; | |
} | |
public string UserName { get; set; } | |
public string Password { get; set; } | |
public bool RememberMe { get; set; } | |
[Hidden] | |
public string ReturnUrl { get; set; } | |
public bool LoginFailed { get; set; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
$(document).ready(function() { | |
var username; | |
var $form = $('form'); | |
var $username = $('input[name=UserName]'); | |
var $password = $('input[name=Password]'); | |
var $rememberme = $('input[name=RememberMe]'); | |
$form.on('submit', function() { | |
username = $rememberme.prop('checked') ? $username.val() : ''; | |
localStorage.setItem('signin:username', username); | |
//For some reason fubu doesn't like to redirect if the rememberMe field is there. | |
$rememberme.remove(); | |
$('label[for=RememberMe]').remove(); | |
}); | |
username = localStorage.getItem('signin:username'); | |
if (username) { | |
$username.val(username); | |
$rememberme.prop('checked', true); | |
$password.focus(); | |
return; | |
} | |
$username.focus(); | |
}); | |
</script> | |
//... html ... | |
<form action="${ this.Urls.UrlFor(new Web.Handlers.user.signin.SignInModel())}" method="POST"> | |
<InputFor property="ReturnUrl" /> | |
<ColumnFor property="UserName" /> | |
<ColumnFor property="Password" /> | |
<ColumnFor property="RememberMe" /> | |
<div class="input controls"> | |
<button type="submit" class="btn btn-primary">Log in</button> | |
</div> | |
<div class="control-group"> | |
<label class="control-label"> </label> | |
<div class="input controls"> | |
${ this.LinkTo<Web.Handlers.user.password.request.PasswordResetGenerateRequest>().Text("Forgot your password?") } | |
</div> | |
</div> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scan(scan => | |
{ | |
//web assembly | |
scan.TheCallingAssembly(); | |
//// snip | |
//fubuvalidation | |
scan.AddAllTypesOf<IValidationRegistration>(); | |
scan.AddAllTypesOf<IFieldValidationSource>(); | |
scan.AddAllTypesOf<IValidationSource>(); | |
scan.AddAllTypesOf<IValidated>(); | |
scan.AddAllTypesOf<ITemplatePartial>(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment