And OpenID, and the usual input in the same form?

Is there any site that shows both OpenID and regular login on the same view? Most sites either have an OpenID implementation, or a regular implementation in different views.

I tried to do this, but it looks like my code is very dirty, passing an empty username and password when using OpenID, otherwise OpenID will be empty, but it will pass the username and password.

But then I lose the opportunity to check if the user has entered the correct values, is there any best practice for me?

thanks a lot

+4
source share
2 answers

Have you looked at NerdDinner ? This is an open source sample that includes the dual sign-in screen that you request. It uses DotNetOpenAuth, so it should also be easy to apply to your site.

+1
source

As requested, here is a site that shows both OpenID and the usual username / password on the same view: https://sourceforge.net/account/login.php

When you create such a page, it is completely normal so that unused form variables are empty. This does not make your code dirty. It simply represents what the user did: he entered the text in some fields and left the rest empty.

You can still validate the values โ€‹โ€‹provided; you just need to add some logic to your controller. In pseudo code, it might look something like this:

if openid_identifier != "": validate_openid( openid_identifier) else: validate_password( username, password) 

It is also worth noting that for OpenID providers that are known to support it, you can use the OpenID 2.0 identifier selection function and provide a simple button, instead of asking the user to dial its OpenID. See the specification for more details.

+1
source

Source: https://habr.com/ru/post/1312531/


All Articles