public ActionResult haveToken(OAuthTokenType type) { var oauth = MASTERdomain.oauth_tokens.SingleOrDefault(x => x.type == type.ToString() && x.authorised); if (oauth == null) { return(Json(false.ToJsonOKData())); } // check that token has not expired if (oauth.expires != null && DateTime.UtcNow > oauth.expires) { repository.DeleteOAuthToken(subdomainid.Value, type); return(Json(false.ToJsonOKData())); } return(Json(true.ToJsonOKData())); }
public void DeleteOAuthToken(long subdomainid, OAuthTokenType type) { var oauth = db.oauth_tokens.SingleOrDefault(x => x.subdomainid == subdomainid && x.type == type.ToString()); if (oauth == null) { Syslog.Write("Can't find {0} token for subdomainid {1}", type, subdomainid); return; } db.oauth_tokens.DeleteOnSubmit(oauth); db.SubmitChanges(); }
public oauth_token GetOAuthToken(string oauth_token, OAuthTokenType type) { var result = db.oauth_tokens.SingleOrDefault(x => x.token_key == oauth_token && x.type == type.ToString()); DeleteOAuthTokenIfExpired(result); return(result); }
public oauth_token GetOAuthToken(long subdomainid, string appid, OAuthTokenType type) { var result = db.oauth_tokens.SingleOrDefault(x => x.subdomainid == subdomainid && x.appid == appid && x.type == type.ToString()); DeleteOAuthTokenIfExpired(result); return(result); }
public oauth_token GetOAuthToken(long subdomainid, OAuthTokenType type, bool?authorised = null) { var token = db.oauth_tokens.Where(x => x.subdomainid == subdomainid && x.type == type.ToString()); if (authorised.HasValue) { token = token.Where(x => x.authorised == authorised.Value); } var result = token.SingleOrDefault(); DeleteOAuthTokenIfExpired(result); return(result); }