Browse Source

Add yahoo and google shortcuts in basic example

tags/0.5
Chris Smith 15 years ago
parent
commit
0c30c67a0b
4 changed files with 19 additions and 1 deletions
  1. BIN
      examples/basic/google.png
  2. 18
    1
      examples/basic/index.php
  3. BIN
      examples/basic/yahoo.png
  4. 1
    0
      processor.php

BIN
examples/basic/google.png View File


+ 18
- 1
examples/basic/index.php View File

@@ -47,6 +47,14 @@
47 47
   // Secondly, if the user is being redirected back from their provider, the
48 48
   // openid.mode parameter will be present (which PHP translates to openid_mode)
49 49
 
50
+  if (isset($_POST['openid_type']) && $_POST['openid_type'] != 'openid_url') {
51
+   // This allows users to select one of the pre-defined identity providers
52
+   // using the provided radio buttons. The values of the radio buttons specify
53
+   // an URL on which we can perform Yadis discovery to find the OpenID
54
+   // endpoint.
55
+   define('OPENID_URL', $_POST['openid_type']);
56
+  }
57
+
50 58
   require('../../processor.php');
51 59
 
52 60
  } else {
@@ -62,6 +70,7 @@
62 70
   <style type="text/css">
63 71
    input#openid_url {
64 72
     background: url('../../openid.gif') no-repeat; padding-left: 20px;
73
+    margin: 5px 0px 0px 40px;
65 74
    }
66 75
 
67 76
    p { padding-left: 10px; }
@@ -69,6 +78,9 @@
69 78
    p.succ { border-left: 10px solid #0f0; }
70 79
    caption { text-align: left; } 
71 80
    table { margin: 10px; }
81
+
82
+   ul { list-style-type: none; }
83
+   input[type="radio"] { width: 20px; }
72 84
   </style>
73 85
  </head>
74 86
  <body>
@@ -118,7 +130,12 @@
118 130
 ?>
119 131
   <form action="<?PHP echo htmlentities($_SERVER['REQUEST_URI']); ?>"
120 132
 	method="post">
121
-   <input type="text" name="openid_url" id="openid_url">
133
+   <ul>
134
+    <li><label><input type="radio" name="openid_type" value="gmail.com"> <img src="google.png" alt="Google"> Log in with my Google account</label></li>
135
+    <li><label><input type="radio" name="openid_type" value="yahoo.com"> <img src="yahoo.png" alt="Yahoo!"> Log in with my Yahoo! account</label></li>
136
+    <li><label><input type="radio" name="openid_type" value="openid_url" checked="checked"> Log in with another OpenID identity:</label> <br>
137
+        <input type="text" name="openid_url" id="openid_url"></li>
138
+   </ul>
122 139
    <input type="submit" value="Login">
123 140
   </form>
124 141
  </body>

BIN
examples/basic/yahoo.png View File


+ 1
- 0
processor.php View File

@@ -246,6 +246,7 @@
246 246
    if ($_SESSION['openid']['delegate'] == 'http://specs.openid.net/auth/2.0/identifier_select') {
247 247
     $_SESSION['openid']['identity'] = $_REQUEST['openid_identity']; 
248 248
     $_SESSION['openid']['delegate'] = $_REQUEST['openid_claimed_id'];
249
+    // TODO: This needs to be verified by perfoming discovery on the url
249 250
    } else {
250 251
      error('diffid', 'Identity provider validated wrong identity. Expected it to '
251 252
   	             . 'validate ' . $_SESSION['openid']['delegate'] . ' but it '

Loading…
Cancel
Save