* 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:
parent
e64d50e94a
commit
5d19dc2dcf
4 changed files with 22 additions and 9 deletions
|
|
@ -60,6 +60,18 @@ namespace Yavsc.Controllers
|
||||||
oa.Login (Response, SetSessionSate ());
|
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>
|
/// <summary>
|
||||||
/// Called after the Google authorizations screen,
|
/// Called after the Google authorizations screen,
|
||||||
|
|
@ -68,7 +80,6 @@ namespace Yavsc.Controllers
|
||||||
/// <returns>The auth.</returns>
|
/// <returns>The auth.</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
|
|
||||||
public ActionResult CalAuth ()
|
public ActionResult CalAuth ()
|
||||||
{
|
{
|
||||||
string msg;
|
string msg;
|
||||||
|
|
@ -221,17 +232,21 @@ namespace Yavsc.Controllers
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public ActionResult ChooseCalendar (string returnUrl)
|
public ActionResult ChooseCalendar (string returnUrl)
|
||||||
{
|
{
|
||||||
Session ["ChooseCalReturnUrl"] = returnUrl;
|
|
||||||
bool hasCalAuth = (bool)HttpContext.Profile.GetPropertyValue ("gcalapi");
|
bool hasCalAuth = (bool)HttpContext.Profile.GetPropertyValue ("gcalapi");
|
||||||
if (!hasCalAuth) {
|
if (!hasCalAuth) {
|
||||||
Session ["returnUrl"] = Request.Url.Scheme + "://" + Request.Url.Authority + "/Google/ChooseCalendar";
|
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 cred = OAuth2.GetFreshGoogleCredential (HttpContext.Profile);
|
||||||
string json;
|
string json;
|
||||||
CalendarApi c = new CalendarApi ();
|
CalendarApi c = new CalendarApi ();
|
||||||
CalendarList cl = c.GetCalendars (cred, out json);
|
CalendarList cl = c.GetCalendars (cred, out json);
|
||||||
ViewData ["json"] = json;
|
ViewData ["json"] = json;
|
||||||
|
ViewData ["returnUrl"] = returnUrl;
|
||||||
return View (cl);
|
return View (cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -242,14 +257,12 @@ namespace Yavsc.Controllers
|
||||||
/// <param name="calchoice">Calchoice.</param>
|
/// <param name="calchoice">Calchoice.</param>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public ActionResult SetCalendar (string calchoice)
|
public ActionResult SetCalendar (string calchoice,string returnUrl)
|
||||||
{
|
{
|
||||||
HttpContext.Profile.SetPropertyValue ("gcalid", calchoice);
|
HttpContext.Profile.SetPropertyValue ("gcalid", calchoice);
|
||||||
HttpContext.Profile.Save ();
|
HttpContext.Profile.Save ();
|
||||||
|
|
||||||
string returnUrl = (string)Session ["ChooseCalReturnUrl"];
|
|
||||||
if (returnUrl != null) {
|
if (returnUrl != null) {
|
||||||
Session ["ChooseCalReturnUrl"] = null;
|
|
||||||
return Redirect (returnUrl);
|
return Redirect (returnUrl);
|
||||||
}
|
}
|
||||||
return Redirect ("/");
|
return Redirect ("/");
|
||||||
|
|
|
||||||
|
|
@ -128,8 +128,7 @@ namespace Yavsc.Helpers.Google
|
||||||
string cont = null;
|
string cont = null;
|
||||||
WebRequest wr = WebRequest.Create (authUri + "?" + prms);
|
WebRequest wr = WebRequest.Create (authUri + "?" + prms);
|
||||||
wr.Method = "GET";
|
wr.Method = "GET";
|
||||||
using (
|
using (WebResponse response = wr.GetResponse ()) {
|
||||||
WebResponse response = wr.GetResponse ()) {
|
|
||||||
string resQuery = response.ResponseUri.Query;
|
string resQuery = response.ResponseUri.Query;
|
||||||
cont = HttpUtility.ParseQueryString (resQuery) ["continue"];
|
cont = HttpUtility.ParseQueryString (resQuery) ["continue"];
|
||||||
response.Close ();
|
response.Close ();
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ table.layout TR TD { max-width:40%; }
|
||||||
<%= Html.TextBox("BlogTitle") %>
|
<%= Html.TextBox("BlogTitle") %>
|
||||||
<%= Html.ValidationMessage("BlogTitle", "*") %></td></tr>
|
<%= Html.ValidationMessage("BlogTitle", "*") %></td></tr>
|
||||||
<tr><td align="right">
|
<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"/>
|
<input type="file" id="AvatarFile" name="AvatarFile"/>
|
||||||
<%= Html.ValidationMessage("AvatarFile", "*") %></td></tr>
|
<%= Html.ValidationMessage("AvatarFile", "*") %></td></tr>
|
||||||
<tr><td align="right">
|
<tr><td align="right">
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
<%=Html.Encode(e.summary)%> <br>
|
<%=Html.Encode(e.summary)%> <br>
|
||||||
<i><%=Html.Encode(e.description)%></i> <br>
|
<i><%=Html.Encode(e.description)%></i> <br>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<input type="hidden" name="returnUrl" id="returnUrl" value="<%=Html.Encode(ViewData["returnUrl"])%>">
|
||||||
<input type="submit">
|
<input type="submit">
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue