This file contains hidden or 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 YayCorp.GuardianSerializer do | |
| @behaviour Guardian.Serializer | |
| alias YayCorp.{Repo, UserAuth} | |
| def for_token(user_auth = %UserAuth{}), do: { :ok, "UserAuth:#{user_auth.id}" } | |
| def for_token(_), do: { :error, "Unknown resource type" } | |
| def from_token("UserAuth:" <> id), do: { :ok, Repo.get(UserAuth, id) } | |
| def from_token(_), do: { :error, "Unknown resource type" } |
This file contains hidden or 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 YayCorp.API.UserController do | |
| use YayCorp.Web, :controller | |
| use Guardian.Phoenix.Controller | |
| alias YayCorp.{User, UserAuth, Repo} | |
| def show(conn, %{"id" => id}, user_auth, _claims) do | |
| requested_user = Repo.get!(User, id) | |
| # users can only retrieve their own details |
This file contains hidden or 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 start(_type, _args) do | |
| import Supervisor.Spec | |
| children = [ | |
| worker(GuardianDb.ExpiredSweeper, []) | |
| # ... | |
| ] | |
| Supervisor.start_link(children, [...]) | |
| end |
This file contains hidden or 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 delete(conn, _params) do | |
| jwt = Guardian.Plug.current_token(conn) | |
| {:ok, claims} = Guardian.Plug.claims(conn) | |
| Guardian.revoke!(jwt, claims) | |
| # ... | |
| end |
This file contains hidden or 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
| package com.example.app; | |
| import com.facebook.react.modules.network.OkHttpClientFactory; | |
| import com.facebook.react.modules.network.OkHttpClientProvider; | |
| import com.facebook.react.modules.network.ReactCookieJarContainer; | |
| import java.util.concurrent.TimeUnit; | |
| import okhttp3.CertificatePinner; | |
| import okhttp3.OkHttpClient; |
This file contains hidden or 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
| import com.example.app.OkHttpCertPin; | |
| import com.facebook.react.modules.network.OkHttpClientProvider; |
This file contains hidden or 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
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| OkHttpClientProvider.setOkHttpClientFactory(new OkHttpCertPin()); | |
| } |
This file contains hidden or 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
| .heading { | |
| font-family: Papyrus; | |
| font-size: 24px; | |
| font-weight: 700; | |
| } |
This file contains hidden or 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
| const styles = StyleSheet.create({ | |
| heading: { | |
| fontFamily: "Papyrus", | |
| fontSize: 24, | |
| fontWeight: 700 | |
| } | |
| }); |
This file contains hidden or 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
| const catsListStyles = StyleSheet.create({ | |
| listContainer: { | |
| backgroundColor: 'red' | |
| } | |
| }); | |
| const dogsListStyles = StyleSheet.create({ | |
| listContainer: { | |
| backgroundColor: 'red' | |
| } | |
| }); |