Skip to content

Instantly share code, notes, and snippets.

@Devalo
Last active May 25, 2016 17:24
Show Gist options
  • Save Devalo/9a089c07c6b5341c3633de319425f00c to your computer and use it in GitHub Desktop.
Save Devalo/9a089c07c6b5341c3633de319425f00c to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Hello Cvapp!</title>
<link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
</head>
<body>
<div class="container">
<header class="header">
<nav role="navigation">
<h1>Some header</h1>
<%= if logged_in?(@conn) do %>
<%= current_user(@conn) %> #doesn't raise
<%= current_user(@conn).email %> #raise undefined function nil.email/0
<%= link "Logout", to: session_path(@conn, :delete, :dont_know_why_i_need_you_but_whatevs_for_now), method: :delete, class: "btn btn-danger" %>
<% else %>
<%= link "Opprett konto ", to: user_path(@conn, :new), class: "btn btn-danger" %>
<%= link "Logg inn", to: session_path(@conn, :new), class: "btn btn-danger" %>
<% end %>
</nav>
<span class="logo"></span>
</header>
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
<main role="main">
<%= render @view_module, @view_template, assigns %>
</main>
</div> <!-- /container -->
<script src="<%= static_path(@conn, "/js/app.js") %>"></script>
</body>
</html>
defmodule Cvapp.GuardianSerializer do
@behaviour Guardian.Serializer
alias Cvapp.Repo
alias Cvapp.User
def for_token(user = %User{}), do: { :ok, "User:#{user.id}"}
def for_token(_), do: { :error, "Unknown resource type"}
def from_token("User:" <> id), do: { :ok, Repo.get(User, id)}
def from_token(_), do: { :error, "Unknown resource type"}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment