Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo | |
@foo ||= begin | |
return 2 | |
1 | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require_relative 'raindrops' | |
class RaindropsTest < Minitest::Test | |
def test_the_sound_for_1_is_1 | |
end | |
def test_the_sound_for_3_is_pling | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User: | |
"""Basic User class""" | |
def __init__(self, name, email, password): | |
self.name = name | |
self.email = email | |
self.password = password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="jumbotron"> | |
<h2><%= gettext "Welcome %{name}", name: @current_user.name %></h2> | |
<p class="lead">A productive web framework that<br />does not compromise speed and maintainability.</p> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def index(conn, _params) do | |
user = Guardian.Plug.current_resource(conn) | |
render conn, "index.html", current_user: user | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule PhoenixUeberauthComeonin.PageController do | |
use PhoenixUeberauthComeonin.Web, :controller | |
plug Guardian.Plug.EnsureAuthenticated, handler: __MODULE__ | |
def index(conn, _params) do | |
render conn, "index.html" | |
end | |
def unauthenticated(conn, _params) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule PhoenixUeberauthComeonin.SessionsController do | |
use PhoenixUeberauthComeonin.Web, :controller | |
alias Ueberauth.Strategy.Helpers | |
plug Ueberauth | |
def new(conn, _params) do | |
render conn, "new.html", callback_url: Helpers.callback_url(conn), current_user: nil | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule GuardianSerializer do | |
@behaviour Guardian.Serializer | |
alias PhoenixUeberauthComeonin.Repo | |
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" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config :guardian, Guardian, | |
allowed_algos: ["HS512"], | |
verify_module: Guardian.JWT, | |
issuer: "Metamorfo", | |
ttl: { 30, :days }, | |
verify_issuer: true, | |
secret_key: <<188, 78, 156, 202, 219, 17, 166, 68, 84, 206, 109, 204, 103, 136, 108, | |
222>>, | |
serializer: GuardianSerializer |
NewerOlder