Commits

Jeff Craig committed d222f99

OpenID Login Page and Beginning OpenID Integration.

  • Participants
  • Parent commits 0fbfd23
  • Branches openid

Comments (0)

Files changed (25)

File CodeCamp/CodeCamp/CodeCamp.csproj

     <Content Include="Content\2010\Sponsors\Z-TechStaffing.png" />
     <Content Include="Content\Images\header-bground.png" />
     <Content Include="Content\Images\logo.png" />
+    <Content Include="Content\Images\OpenID\aolW.png" />
+    <Content Include="Content\Images\OpenID\blogger.png" />
+    <Content Include="Content\Images\OpenID\claimid.png" />
+    <Content Include="Content\Images\OpenID\facebookW.png" />
+    <Content Include="Content\Images\OpenID\flickr.png" />
+    <Content Include="Content\Images\OpenID\flickrW.png" />
+    <Content Include="Content\Images\OpenID\googleW.png" />
+    <Content Include="Content\Images\OpenID\livejournal.png" />
+    <Content Include="Content\Images\OpenID\myopenid.png" />
+    <Content Include="Content\Images\OpenID\myopenidW.png" />
+    <Content Include="Content\Images\OpenID\myspaceW.png" />
+    <Content Include="Content\Images\OpenID\openidico.png" />
+    <Content Include="Content\Images\OpenID\openidW.png" />
+    <Content Include="Content\Images\OpenID\technorati.png" />
+    <Content Include="Content\Images\OpenID\verisign.png" />
+    <Content Include="Content\Images\OpenID\vidoop.png" />
+    <Content Include="Content\Images\OpenID\wordpress.png" />
+    <Content Include="Content\Images\OpenID\yahooW.png" />
     <Content Include="Content\Images\PortlandPanorama.jpg" />
     <Content Include="Content\nav.css" />
     <Content Include="Content\reset.css" />
     <Content Include="Global.asax" />
     <Content Include="Scripts\custom.js" />
     <Content Include="Scripts\jquery-1.4.2.min.js" />
+    <Content Include="Scripts\jquery.openid.js" />
     <Content Include="Scripts\jquery.pcc.js" />
     <Content Include="Scripts\plugins.js" />
     <Content Include="Views\Account\Create.aspx" />

File CodeCamp/CodeCamp/Content/Images/OpenID/aolW.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/blogger.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/claimid.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/facebookW.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/flickr.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/flickrW.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/googleW.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/livejournal.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/myopenid.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/myopenidW.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/myspaceW.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/openidW.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/openidico.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/technorati.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/verisign.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/vidoop.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/wordpress.png

Added
New image

File CodeCamp/CodeCamp/Content/Images/OpenID/yahooW.png

Added
New image

File CodeCamp/CodeCamp/Content/openid.css

+body {font-family: Arial;}
+fieldset {border-style:none;}
+img {border-style:none;}
+
+#content form.openid ul { text-align:center; list-style-type:none; display:inline;}
+#content form.openid ul li {float:left; padding:4px; background: none;}
+#content form.openid ul li span {padding:0 1em 0 3px}
+#content form.openid fieldset {clear:both; padding:1em 0}
+#content form.openid div+fieldset {display:none}
+#content form.openid label {display:block; font-weight:bold; font-size:larger; margin-bottom:.5em}
+input[name=openid_username] {width:8em}
+input[name=openid_identifier] {width:18em}
+#content form.openid ul li.highlight { -moz-border-radius:4px; -webkit-border-radius:4px; background-color: #FD6}
+#content form.openid fieldset div {font-family:arial;-moz-border-radius:4px; -webkit-border-radius:4px; 
+                          background: #DCDCDC url(images/fadegrey.png); padding:10px;display:inline-block}
+#content form.openid input[type='submit'] {margin-left:1em;}
+
+.openid_logo{color:#F7931E;padding:6px 0px 8px 28px; background: url(/Content/Images/OpenID/openidico.png) no-repeat}
+
+#openid_login{float:left; font-size:larger; width:30%; margin:2em 1em; text-align:center}
+#openid_login div{margin-top:0.5em}
+#openid_login div+span{font-size:smaller}

File CodeCamp/CodeCamp/Controllers/AccountController.cs

       MembershipService = service ?? new AccountMembershipService();
     }
 
+    private static OpenIdRelyingParty openid = new OpenIdRelyingParty();
+
     public IFormsAuthentication FormsAuth
     {
       get;
     [AcceptVerbs( HttpVerbs.Post )]
     [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings",
         Justification = "Needs to take same parameter type as Controller.Redirect()" )]
-    public ActionResult SignIn( string userName, string password, bool rememberMe, string returnUrl )
+    public ActionResult SignIn( string userName, string password, string returnUrl )
     {
 
       if ( !ValidateLogOn( userName, password ) )
         return View();
       }
 
-      FormsAuth.SignIn( userName, rememberMe );
+      FormsAuth.SignIn( userName, false);
       if ( !String.IsNullOrEmpty( returnUrl ) )
       {
         return Redirect( returnUrl );

File CodeCamp/CodeCamp/Controllers/CodeCampDataRepository.cs

       context01.SubmitChanges();
       context02.SubmitChanges();
     }
-
   }
 }

File CodeCamp/CodeCamp/Scripts/jquery.openid.js

+//jQuery OpenID Plugin 1.1 Copyright 2009 Jarrett Vance http://jvance.com/pages/jQueryOpenIdPlugin.xhtml
+$.fn.openid = function() {
+  var $this = $(this);
+  var $usr = $this.find('input[name=openid_username]');
+  var $id = $this.find('input[name=openid_identifier]');
+  var $front = $this.find('div:has(input[name=openid_username])>span:eq(0)');
+  var $end = $this.find('div:has(input[name=openid_username])>span:eq(1)');
+  var $usrfs = $this.find('fieldset:has(input[name=openid_username])');
+  var $idfs = $this.find('fieldset:has(input[name=openid_identifier])');
+
+  var submitusr = function() {
+    if ($usr.val().length < 1) {
+      $usr.focus();
+      return false;
+    }
+    $id.val($front.text() + $usr.val() + $end.text());
+    return true;
+  };
+
+  var submitid = function() {
+    if ($id.val().length < 1) {
+      $id.focus();
+      return false;
+    }
+    return true;
+
+  };
+  var direct = function() {
+    var $li = $(this);
+    $li.parent().find('li').removeClass('highlight');
+    $li.addClass('highlight');
+    $usrfs.fadeOut();
+    $idfs.fadeOut();
+
+    $this.unbind('submit').submit(function() {
+      $id.val($this.find("li.highlight span").text());
+    });
+    $this.submit();
+    return false;
+  };
+
+  var openid = function() {
+    var $li = $(this);
+    $li.parent().find('li').removeClass('highlight');
+    $li.addClass('highlight');
+    $usrfs.hide();
+    $idfs.show();
+    $id.focus();
+    $this.unbind('submit').submit(submitid);
+    return false;
+  };
+
+  var username = function() {
+    var $li = $(this);
+    $li.parent().find('li').removeClass('highlight');
+    $li.addClass('highlight');
+    $idfs.hide();
+    $usrfs.show();
+    $this.find('label[for=openid_username] span').text($li.attr("title"));
+    $front.text($li.find("span").text().split("username")[0]);
+    $end.text("").text($li.find("span").text().split("username")[1]);
+    $id.focus();
+    $this.unbind('submit').submit(submitusr);
+    return false;
+  };
+
+  $this.find('li.direct').click(direct);
+  $this.find('li.openid').click(openid);
+  $this.find('li.username').click(username);
+  $id.keypress(function(e) {
+    if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
+      return submitid();
+    }
+  });
+  $usr.keypress(function(e) {
+    if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
+      return submitusr();
+    }
+  });
+  $this.find('li span').hide();
+  $this.find('li').css('line-height', 0).css('cursor', 'pointer');
+  $this.find('li:eq(0)').click();
+  return this;
+};

File CodeCamp/CodeCamp/Views/Account/SignIn.aspx

 <asp:Content ID="signinTitle" ContentPlaceHolderID="TitleContent" runat="server">
   Log On
 </asp:Content>
+<asp:Content ContentPlaceHolderID="SpecificHeaderInfo" runat="server">
+  <link rel="Stylesheet" type="text/css" href="/Content/openid.css" />
+</asp:Content>
+
 <asp:Content ID="signinContent" ContentPlaceHolderID="MainContent" runat="server">
   <h2>
     Presenter Sign In
   </h2>
-  <h3>
-    If you don't have one, you can
-    <%= Html.ActionLink("create a presenter account", "Create") %> now.
-  </h3>
   <%= Html.ValidationSummary("Login was unsuccessful. Please correct the errors and try again.") %>
-  <% using ( Html.BeginForm() )
-     { %>
+    <form action="/Account/SignIn?ReturnUrl=<%=HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]) %>" method="post" class="openid">
       <div>
-        <fieldset>
-          <legend>Account Information</legend>
-          <div>
-            <label for="username">
-              Username:</label>
-            <%= Html.TextBox("username") %>
-            <%= Html.ValidationMessage("username") %>
-          </div>
-          <div>
-            <label for="password">
-              Password:</label>
-            <%= Html.Password("password") %>
-            <%= Html.ValidationMessage("password") %>
-          </div>
-          <div>
-            <%= Html.CheckBox("rememberMe") %>
-            <label class="inline" for="rememberMe">
-              Remember me:</label>
-          </div>
-          <div>
-            <input type="submit" value="Sign in" />
-          </div>
-        </fieldset>
+          <p>Do you already have an account on one of these sites? You can use that to log on here!</p>
+          <ul class="providers">
+            <li class="openid" title="MyOpenID"><img src="/Content/Images/OpenID/myopenidW.png" alt="MyOpenID" /><span>http://<strong>username</strong>.myopenid.com/</span></li>
+            <li class="direct" title="Google"><img src="/Content/Images/OpenID/googleW.png" alt="Google" /><span>https://www.google.com/accounts/o8/id</span></li>
+            <li class="direct" title="Yahoo"><img src="/Content/Images/OpenID/yahooW.png" alt="Yahoo!" /><span>http://yahoo.com/</span></li>
+          </ul>
+          <fieldset>
+            <label for="openid_username">Enter you <span>Provider user name</span></label>
+            <div><span></span><input type="text" name="openid_username" /><span></span><input type="submit" value="Login" /></div>
+          </fieldset>
+          <fieldset>
+            <label for="openid_identifier">Enter your <a class="openid_logo" href="http://openid.net">OpenID</a></label>
+            <div><input type="text" name="openid_identifier" /><input type="submit" value="Login" /></div>
+          </fieldset>
       </div>
-  <% } %>
+    </form>
+    <script type="text/javascript" src="/Scripts/jquery.openid.js"></script>
+    <script type="text/javascript">$(function() { $("form.openid").openid(); });</script>
 </asp:Content>

File CodeCamp/CodeCamp/Views/Shared/Site.Master

   <link rel="stylesheet" href="<%= Url.Content("~/Content/Style.css") %>" type="text/css" media="screen" />
   <link rel="stylesheet" href="<%= Url.Content("~/Content/Style1.css") %>" type="text/css" media="screen" />
 
+  <asp:ContentPlaceHolder ID="SpecificHeaderInfo" runat="server" />
 </head>
 <body>