* GoogleController.cs: Restores the calendar choosing
* OAuth2.cs: code formatting * Profile.aspx: useless Uri display * ChooseCalendar.aspx: returnUrl in the calendar choosing process
This commit is contained in:
@ -60,6 +60,18 @@ namespace Yavsc.Controllers
|
||||
oa.Login (Response, SetSessionSate ());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cal auth.
|
||||
/// </summary>
|
||||
/// <param name="returnUrl">Return URL.</param>
|
||||
public void GetCalAuth (string returnUrl)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace (returnUrl))
|
||||
returnUrl = "/";
|
||||
Session ["returnUrl"] = returnUrl;
|
||||
OAuth2 oa = new OAuth2 (CalendarGRU);
|
||||
oa.GetCalAuth (Response, SetSessionSate ());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after the Google authorizations screen,
|
||||
@ -68,7 +80,6 @@ namespace Yavsc.Controllers
|
||||
/// <returns>The auth.</returns>
|
||||
[HttpGet]
|
||||
[Authorize]
|
||||
|
||||
public ActionResult CalAuth ()
|
||||
{
|
||||
string msg;
|
||||
@ -221,17 +232,21 @@ namespace Yavsc.Controllers
|
||||
[HttpGet]
|
||||
public ActionResult ChooseCalendar (string returnUrl)
|
||||
{
|
||||
Session ["ChooseCalReturnUrl"] = returnUrl;
|
||||
|
||||
bool hasCalAuth = (bool)HttpContext.Profile.GetPropertyValue ("gcalapi");
|
||||
if (!hasCalAuth) {
|
||||
Session ["returnUrl"] = Request.Url.Scheme + "://" + Request.Url.Authority + "/Google/ChooseCalendar";
|
||||
return RedirectToAction ("GetCalAuth");
|
||||
return RedirectToAction ("GetCalAuth",
|
||||
new {
|
||||
returnUrl = "ChooseCalendar?returnUrl="+HttpUtility.UrlEncode(returnUrl)
|
||||
});
|
||||
}
|
||||
string cred = OAuth2.GetFreshGoogleCredential (HttpContext.Profile);
|
||||
string json;
|
||||
CalendarApi c = new CalendarApi ();
|
||||
CalendarList cl = c.GetCalendars (cred, out json);
|
||||
ViewData ["json"] = json;
|
||||
ViewData ["returnUrl"] = returnUrl;
|
||||
return View (cl);
|
||||
}
|
||||
|
||||
@ -242,14 +257,12 @@ namespace Yavsc.Controllers
|
||||
/// <param name="calchoice">Calchoice.</param>
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public ActionResult SetCalendar (string calchoice)
|
||||
public ActionResult SetCalendar (string calchoice,string returnUrl)
|
||||
{
|
||||
HttpContext.Profile.SetPropertyValue ("gcalid", calchoice);
|
||||
HttpContext.Profile.Save ();
|
||||
|
||||
string returnUrl = (string)Session ["ChooseCalReturnUrl"];
|
||||
if (returnUrl != null) {
|
||||
Session ["ChooseCalReturnUrl"] = null;
|
||||
return Redirect (returnUrl);
|
||||
}
|
||||
return Redirect ("/");
|
||||
|
@ -128,8 +128,7 @@ namespace Yavsc.Helpers.Google
|
||||
string cont = null;
|
||||
WebRequest wr = WebRequest.Create (authUri + "?" + prms);
|
||||
wr.Method = "GET";
|
||||
using (
|
||||
WebResponse response = wr.GetResponse ()) {
|
||||
using (WebResponse response = wr.GetResponse ()) {
|
||||
string resQuery = response.ResponseUri.Query;
|
||||
cont = HttpUtility.ParseQueryString (resQuery) ["continue"];
|
||||
response.Close ();
|
||||
|
@ -57,7 +57,7 @@ table.layout TR TD { max-width:40%; }
|
||||
<%= Html.TextBox("BlogTitle") %>
|
||||
<%= Html.ValidationMessage("BlogTitle", "*") %></td></tr>
|
||||
<tr><td align="right">
|
||||
Avatar : "<%=Model.avatar%>" </td><td> <img class="avatar" src="<%=Model.avatar%>" alt=""/>
|
||||
Avatar </td><td> <img class="avatar" src="<%=Model.avatar%>" alt=""/>
|
||||
<input type="file" id="AvatarFile" name="AvatarFile"/>
|
||||
<%= Html.ValidationMessage("AvatarFile", "*") %></td></tr>
|
||||
<tr><td align="right">
|
||||
|
@ -8,6 +8,7 @@
|
||||
<%=Html.Encode(e.summary)%> <br>
|
||||
<i><%=Html.Encode(e.description)%></i> <br>
|
||||
<% } %>
|
||||
<input type="hidden" name="returnUrl" id="returnUrl" value="<%=Html.Encode(ViewData["returnUrl"])%>">
|
||||
<input type="submit">
|
||||
<% } %>
|
||||
|
||||
|
Reference in New Issue
Block a user