package controllers;

import play.mvc.*;
import play.libs.OpenID;
import play.libs.OpenID.*;

public class Authentication extends Controller {
    public static void login() {
        render();
    }

    public static void logout() {
        session.clear();
        redirect("/");
    }
    
    public static void authenticate(String user) {
        if(OpenID.isAuthenticationResponse()) {
            UserInfo verifiedUser = OpenID.getVerifiedID();
            if(verifiedUser == null) {
                flash.put("error", "Oops. Authentication has failed");
                login();
            } 
            session.put("user", verifiedUser.id);
            // TODO - we should complete registration here
            redirect("/");
        } else {
            OpenID.id(user).verify(); // will redirect the user
        }
    }

}
@@ -15,16 +15,36 @@
 llers;%0A%0A
+import models.User;%0A
 import p
@@ -666,16 +666,113 @@
 er.id);%0A
+            User u = new User();%0A            u.openID = verifiedUser.id;%0A            u.insert();%0A
         

Create new user