You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@esme.apache.org by vd...@apache.org on 2010/02/08 22:14:24 UTC
svn commit: r907799 - in /incubator/esme/trunk/server/src/main:
resources/ESMEUI.properties scala/org/apache/esme/lib/ProfileMgr.scala
webapp/profile_view/edit.html
Author: vdichev
Date: Mon Feb 8 21:14:24 2010
New Revision: 907799
URL: http://svn.apache.org/viewvc?rev=907799&view=rev
Log:
ESME-111 Configure OpenID
Modified:
incubator/esme/trunk/server/src/main/resources/ESMEUI.properties
incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ProfileMgr.scala
incubator/esme/trunk/server/src/main/webapp/profile_view/edit.html
Modified: incubator/esme/trunk/server/src/main/resources/ESMEUI.properties
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/resources/ESMEUI.properties?rev=907799&r1=907798&r2=907799&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/resources/ESMEUI.properties (original)
+++ incubator/esme/trunk/server/src/main/resources/ESMEUI.properties Mon Feb 8 21:14:24 2010
@@ -25,6 +25,7 @@
ui_sign_up_image_url=URL for Avatar Image
ui_sign_up_timezone=Your Timezone
ui_sign_up_locale=Your Locale
+ui_sign_up_openid=Your OpenID provider URL
ui_login_email=Email
ui_login_password=Password
Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ProfileMgr.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ProfileMgr.scala?rev=907799&r1=907798&r2=907799&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ProfileMgr.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ProfileMgr.scala Mon Feb 8 21:14:24 2010
@@ -39,6 +39,9 @@
import model._
+import org.openid4java.discovery.Identifier
+import org.openid4java.consumer._
+
import scala.xml._
/**
@@ -55,14 +58,55 @@
Nil
def editProfile(in: NodeSeq): NodeSeq = {
+ import OpenIDAuthModule.moduleName
(for (user <- User.currentUser) yield {
+
+ val openID = UserAuth.find(By(UserAuth.user, user),
+ By(UserAuth.authType, moduleName))
+
+ val openIdUrl = openID.map(_.authKey.is) getOrElse ""
+ val from = "/profile_view/edit"
+
+ def saveOpenID(openid: Box[Identifier], fo: Box[VerificationResult], exp: Box[Exception]): LiftResponse = {
+ (openid, exp) match {
+ case (Full(id), _) =>
+ UserAuth.create.authType(moduleName).user(user).authKey(id.getIdentifier()).save
+
+ case (_, Full(exp)) =>
+ S.error(S.?("base_error_exception", exp.getMessage))
+
+ case _ =>
+ S.error(S.?("base_user_err_login", fo.map(_.getStatusMsg)))
+ }
+ RedirectResponse(from, S responseCookies :_*)
+ }
+
+ def registerOpenID (url: String) {
+ if (openIdUrl != url) {
+ if (url != "") {
+ val other = UserAuth.find(NotBy(UserAuth.user, user),
+ By(UserAuth.authType, moduleName),
+ By(UserAuth.authKey, url))
+ other match {
+ case Empty =>
+ ESMEOpenIDVendor.loginAndRedirect(url, saveOpenID)
+ // TODO: localize
+ case _ => S.error("This OpenID URL is registered with another user!")
+ }
+ } else {
+ for (auth <- openID) auth.delete_!
+ }
+ }
+ }
+
bind("user", in, "nickname" -> text(user.nickname, {_ =>}, "disabled" -> "true"),
"lastName" -> user.lastName.toForm,
"imageURL" -> user.imageUrl.toForm,
"firstName" -> user.firstName.toForm,
"timezone" -> user.timezone.toForm,
"locale" -> user.locale.toForm,
+ "openid" -> text(openIdUrl, registerOpenID(_)),
"save" -> submit("Save", user.save))
}).getOrElse(NodeSeq.Empty)
Modified: incubator/esme/trunk/server/src/main/webapp/profile_view/edit.html
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/webapp/profile_view/edit.html?rev=907799&r1=907798&r2=907799&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/webapp/profile_view/edit.html (original)
+++ incubator/esme/trunk/server/src/main/webapp/profile_view/edit.html Mon Feb 8 21:14:24 2010
@@ -26,6 +26,7 @@
<tr> <td><lift:loc>ui_sign_up_image_url</lift:loc></td> <td><user:imageURL/></td> </tr>
<tr> <td><lift:loc>ui_sign_up_timezone</lift:loc></td> <td><user:timezone/></td> </tr>
<tr> <td><lift:loc>ui_sign_up_locale</lift:loc></td> <td><user:locale/></td> </tr>
+ <tr> <td><lift:loc>ui_sign_up_openid</lift:loc></td> <td><user:openid/></td> </tr>
<user:save/>
</tbody>
</table>