package utils;

import models.User;
import play.Logger;
import play.Logger.ALogger;
import play.mvc.Http.Context;
import socialauth.controllers.SocialLogin;
import socialauth.core.SocialUser;

public class HttpUtils {

	private static ALogger log = Logger.of(HttpUtils.class);
	
	public static String selfURL() {
		// TODO Auto-generated method stub
		return null;
	}

	/**
	 * extract login user from the context if available
	 * @param ctx http context
	 * @return login user, or null
	 */
	public static User loginUser(Context ctx) {
		final SocialUser su = (SocialUser) ctx.args.get(SocialLogin.USER_KEY);
		if (log.isDebugEnabled())
			log.debug("su : " + su);
		User user = null;
		if (su != null)
			user  = new User(su);
		if (log.isDebugEnabled())
			log.debug("user : " + user);
		return user;
	}

}

@@ -696,17 +696,173 @@
 != null)
+ %7B
 %0A
+%09%09%09user = User.get(su.getUserKey());%0A%09%09%09if (user == null) %7B%0A%09%09%09%09if (log.isDebugEnabled())%0A%09%09%09%09%09log.debug(%22user not found in DB, creating from session%22);%0A%09
 %09%09%09user 
@@ -878,16 +878,25 @@
 er(su);%0A
+%09%09%09%7D%0A%09%09%7D%0A
 %09%09if (lo

fix minor problem creating a user from session