Exemplo n.º 1
0
Arquivo: auth.go Projeto: xeb/flowdle
func (c Auth) Index() revel.Result {
	tokenCache := services.NewOAuthCache(c.Session, bucket)
	r, _ := services.TryOAuth(*tokenCache, "")

	if r.Success == false {
		return c.Redirect(r.AuthURL)
	}

	c.Session["username"] = r.Account.Name
	return c.Redirect("/tasks")
}
Exemplo n.º 2
0
Arquivo: auth.go Projeto: xeb/flowdle
func (c Auth) Callback() revel.Result {
	tokenCache := services.NewOAuthCache(c.Session, bucket)
	code := c.Params.Get("code")
	r, err := services.TryOAuth(tokenCache, code)
	if err != nil {
		return c.RenderText(fmt.Sprintf("%s", err))
	}

	c.Session["userid"] = r.Account.Id
	c.Session["username"] = r.Account.Name
	c.Session["userimg"] = r.Account.Picture

	if r.Success {
		return c.Redirect("/tasks")
	}

	c.Response.Status = 401
	return c.RenderText("Unauthorized")
}