mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
show error page puzzle link only for premium users
This commit is contained in:
@@ -30,4 +30,13 @@ defmodule Chesstrainer.Accounts.Scope do
|
||||
end
|
||||
|
||||
def for_user(nil), do: nil
|
||||
|
||||
@doc """
|
||||
True when the scope belongs to a premium user.
|
||||
|
||||
`for_user/1` returns `nil` for anonymous visitors, so the catch-all covers
|
||||
both nil scopes and free plans.
|
||||
"""
|
||||
def premium?(%__MODULE__{user: %User{plan: :premium}}), do: true
|
||||
def premium?(_scope), do: false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user