Files
Claper/ClaperWeb.UserAuth.html
2022-07-28 14:39:02 +00:00

333 lines
10 KiB
HTML

<!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.0">
<meta name="generator" content="ExDoc v0.28.4">
<meta name="project" content="Claper v1.0.0">
<title>ClaperWeb.UserAuth — Claper v1.0.0</title>
<link rel="stylesheet" href="dist/elixir-b6f1ed5df9b1d42a7309.css" />
<script src="dist/sidebar_items-37c81d9b39.js"></script>
<script src="docs_config.js"></script>
<script async src="dist/app-bd1cb213813bf4825aa2.js"></script>
</head>
<body data-type="modules">
<script>
try {
var settings = JSON.parse(localStorage.getItem('ex_doc:settings') || '{}');
if (settings.theme === 'dark' ||
((settings.theme === 'system' || settings.theme == null) &&
window.matchMedia('(prefers-color-scheme: dark)').matches)
) {
document.body.classList.add('dark')
}
} catch (error) { }
</script>
<div class="main">
<section class="sidebar">
<button class="sidebar-button sidebar-toggle" aria-label="toggle sidebar">
<i class="ri-menu-line ri-lg" title="Collapse/expand sidebar"></i>
</button>
<form class="sidebar-search" action="search.html">
<button type="submit" class="search-button" aria-label="Submit Search">
<i class="ri-search-2-line" aria-hidden="true" title="Submit search"></i>
</button>
<button type="button" tabindex="-1" class="search-close-button" aria-label="Cancel Search">
<i class="ri-close-line ri-lg" aria-hidden="true" title="Cancel search"></i>
</button>
<label class="search-label">
<p class="sr-only">Search</p>
<input name="q" type="text" class="search-input" placeholder="Search..." aria-label="Input your search terms" autocomplete="off" />
</label>
</form>
<div class="autocomplete">
<div class="autocomplete-results">
</div>
</div>
<div class="sidebar-header">
<a href="https://get.claper.co">
<img src="assets/logo.png" alt="Claper" class="sidebar-projectImage">
</a>
<div class="sidebar-projectDetails">
<a href="https://get.claper.co" class="sidebar-projectName" translate="no">
Claper
</a>
<strong class="sidebar-projectVersion" translate="no">
v1.0.0
</strong>
</div>
<ul class="sidebar-listNav">
<li><a id="extras-list-link" href="#full-list">GUIDES</a></li>
<li><a id="modules-list-link" href="#full-list">Modules</a></li>
</ul>
</div>
<div class="gradient"></div>
<ul id="full-list" class="sidebar-fullList"></ul>
</section>
<section class="content">
<output role="status" id="toast"></output>
<div class="content-outer">
<div id="content" class="content-inner">
<h1>
<button class="settings display-settings">
<i class="ri-settings-3-line"></i>
<span class="sr-only">Settings</span>
</button>
<a href="https://github.com/ClaperCo/Claper/blob/v1.0.0/lib/claper_web/controllers/user_auth.ex#L1" title="View Source" class="view-source" rel="help">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
<span translate="no">ClaperWeb.UserAuth</span>
<small class="app-vsn" translate="no">(Claper v1.0.0)</small>
</h1>
<section id="summary" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#summary">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this section</span>
</a>
Summary
</h1>
<div class="summary-functions summary">
<h2>
<a href="#functions">Functions</a>
</h2>
<div class="summary-row">
<div class="summary-signature">
<a href="#fetch_current_user/2" translate="no">fetch_current_user(conn, opts)</a>
</div>
<div class="summary-synopsis"><p>Authenticates the user by looking into the session
and remember me token.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#log_in_user/3" translate="no">log_in_user(conn, user, params \\ %{})</a>
</div>
<div class="summary-synopsis"><p>Logs the user in.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#log_out_user/1" translate="no">log_out_user(conn)</a>
</div>
<div class="summary-synopsis"><p>Logs the user out.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#redirect_if_user_is_authenticated/2" translate="no">redirect_if_user_is_authenticated(conn, opts)</a>
</div>
<div class="summary-synopsis"><p>Used for routes that require the user to not be authenticated.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#require_authenticated_user/2" translate="no">require_authenticated_user(conn, opts)</a>
</div>
<div class="summary-synopsis"><p>Used for routes that require the user to be authenticated.</p></div>
</div>
</div>
</section>
<section id="functions" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#functions">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this section</span>
</a>
Functions
</h1>
<div class="functions-list">
<section class="detail" id="fetch_current_user/2">
<div class="detail-header">
<a href="#fetch_current_user/2" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">fetch_current_user(conn, opts)</h1>
<a href="https://github.com/ClaperCo/Claper/blob/v1.0.0/lib/claper_web/controllers/user_auth.ex#L91" class="view-source" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Authenticates the user by looking into the session
and remember me token.</p>
</section>
</section>
<section class="detail" id="log_in_user/3">
<span id="log_in_user/2"></span>
<div class="detail-header">
<a href="#log_in_user/3" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">log_in_user(conn, user, params \\ %{})</h1>
<a href="https://github.com/ClaperCo/Claper/blob/v1.0.0/lib/claper_web/controllers/user_auth.ex#L27" class="view-source" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Logs the user in.</p><p>It renews the session ID and clears the whole session
to avoid fixation attacks. See the renew_session
function to customize this behaviour.</p><p>It also sets a <code class="inline">:live_socket_id</code> key in the session,
so LiveView sessions are identified and automatically
disconnected on log out. The line can be safely removed
if you are not using LiveView.</p>
</section>
</section>
<section class="detail" id="log_out_user/1">
<div class="detail-header">
<a href="#log_out_user/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">log_out_user(conn)</h1>
<a href="https://github.com/ClaperCo/Claper/blob/v1.0.0/lib/claper_web/controllers/user_auth.ex#L73" class="view-source" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Logs the user out.</p><p>It clears all session data for safety. See renew_session.</p>
</section>
</section>
<section class="detail" id="redirect_if_user_is_authenticated/2">
<div class="detail-header">
<a href="#redirect_if_user_is_authenticated/2" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">redirect_if_user_is_authenticated(conn, opts)</h1>
<a href="https://github.com/ClaperCo/Claper/blob/v1.0.0/lib/claper_web/controllers/user_auth.ex#L114" class="view-source" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Used for routes that require the user to not be authenticated.</p>
</section>
</section>
<section class="detail" id="require_authenticated_user/2">
<div class="detail-header">
<a href="#require_authenticated_user/2" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">require_authenticated_user(conn, opts)</h1>
<a href="https://github.com/ClaperCo/Claper/blob/v1.0.0/lib/claper_web/controllers/user_auth.ex#L130" class="view-source" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Used for routes that require the user to be authenticated.</p><p>If you want to enforce the user email is confirmed before
they use the application at all, here would be a good place.</p>
</section>
</section>
</div>
</section>
<footer class="footer">
<p>
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" target="_blank" rel="help noopener" translate="no">ExDoc</a> (v0.28.4) for the
<a href="https://elixir-lang.org" title="Elixir" target="_blank" translate="no">Elixir programming language</a>
</p>
</footer>
</div>
</div>
</section>
</div>
</body>
</html>