-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathrouter.ex
33 lines (27 loc) · 911 Bytes
/
router.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
defmodule GoogleOAuth2Example.Router do
use GoogleOAuth2Example.Web, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
plug :assign_current_user
end
scope "/", GoogleOAuth2Example do
pipe_through :browser # Use the default browser stack
get "/", PageController, :index
end
scope "/auth", GoogleOAuth2Example do
pipe_through :browser
get "/", AuthController, :index
get "/callback", AuthController, :callback
delete "/logout", AuthController, :delete
end
# Fetch the current user from the session and add it to `conn.assigns`. This
# will allow you to have access to the current user in your views with
# `@current_user`.
defp assign_current_user(conn, _) do
assign(conn, :current_user, get_session(conn, :current_user))
end
end