views:

54

answers:

2

Hi there,

Is there any site that show both OpenID and normal login on the same view? Most of the sites either have OpenID implementation or Normal Login implementation on different views.

I tried to do that, but it seems my code is very dirty, passing a blank username and password if using OpenID, otherwise OpenID will be blank but passed the username and password.

But then I lose the capability of verifying whether the user has entered the correct values, is there any best practice for me to do that?

Thanks a lot

+1  A: 

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

When you create a page like that, it's perfectly normal for the unused form variables to be empty. It doesn't make your code dirty. It simply represents what the user did: he entered text in some fields and left the others blank.

You can still validate that submitted values are correct; you simply have to add a little more logic to your controller. In pseudocode, it might look something like this:

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

It's also worth noting that, for OpenID providers that are known to support it, you can use the identifier select feature of OpenID 2.0 and provide a simple button instead of asking the user to type his OpenID. See the spec for details.

Forest
Yech. It's a correct answer, but I wouldn't use SourceForge as a good example. The UI is poor, and the OpenID implementation is worse.
Andrew Arnott
+1  A: 

Have you taken a look at NerdDinner? It's an open source sample that includes the dual login screen that you're asking for. It uses DotNetOpenAuth, so it should be easy to apply to your site as well.

Andrew Arnott