mirror of
https://github.com/mgerb/classic-wow-forums
synced 2026-01-09 00:42:47 +00:00
client/server - update message - update authentication
This commit is contained in:
@@ -6,7 +6,6 @@ import './home.scss';
|
|||||||
|
|
||||||
import header_forms from '../../assets/header-forums.gif';
|
import header_forms from '../../assets/header-forums.gif';
|
||||||
import support from '../../assets/support.gif';
|
import support from '../../assets/support.gif';
|
||||||
// import serverstatus from '../../assets/serverstatus.gif';
|
|
||||||
import uicustomizations from '../../assets/uicustomizations.gif';
|
import uicustomizations from '../../assets/uicustomizations.gif';
|
||||||
import bugs from '../../assets/bugs.gif';
|
import bugs from '../../assets/bugs.gif';
|
||||||
import realms from '../../assets/realms.gif';
|
import realms from '../../assets/realms.gif';
|
||||||
@@ -94,9 +93,10 @@ export class Home extends React.Component<Props, State> {
|
|||||||
<b>Welcome to the unofficial Classic WoW Forums!</b>
|
<b>Welcome to the unofficial Classic WoW Forums!</b>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
This site is made with the intention of providing a web forum
|
I created this site with the intention of providing
|
||||||
that replicates the World of Warcraft forums as they were
|
a fully functional and accurate representation of
|
||||||
back in 2005.
|
the World of Warcraft forums as they were
|
||||||
|
back in 2005. <Link to={'/t/137/1'}>Please read this first!</Link>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ div {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.blue-post {
|
.blue-post {
|
||||||
p {
|
p, li, {
|
||||||
color: $bluePost;
|
color: $bluePost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
defmodule MyApp.Guardian.Auth.Token do
|
defmodule MyApp.Guardian.Auth.Token do
|
||||||
alias MyApp.Guardian
|
alias MyApp.Guardian
|
||||||
|
|
||||||
|
# one month in seconds
|
||||||
|
defp one_month(), do: 2592000
|
||||||
|
|
||||||
@spec add_token_and_map_claims(map | {atom, any}) :: {:ok, map} | {:error, String.t}
|
@spec add_token_and_map_claims(map | {atom, any}) :: {:ok, map} | {:error, String.t}
|
||||||
def add_token_and_map_claims(user) when is_map(user) do
|
def add_token_and_map_claims(user) when is_map(user) do
|
||||||
|
|
||||||
claims = user
|
claims = user
|
||||||
|> Map.take([:id, :battletag, :battle_net_id, "access_token"]) # take values from user object to map to claims
|
|> Map.take([:id, :battletag, :battle_net_id, :access_token]) # take values from user object to map to claims
|
||||||
|> Guardian.add_permissions(get_permissions(user))
|
|> Guardian.add_permissions(get_permissions(user))
|
||||||
|
|
||||||
# set token expiration to the same as the battlenet token
|
# set token expiration to the same as the battlenet token
|
||||||
case Guardian.encode_and_sign(user, claims, ttl: {user["expires_in"], :seconds}) do
|
case Guardian.encode_and_sign(user, claims, ttl: {Map.get(user, :expires_in) || one_month(), :seconds}) do
|
||||||
{:ok, token, _claims} -> {:ok, Map.merge(user, %{token: token})}
|
{:ok, token, _claims} -> {:ok, Map.merge(user, %{token: token})}
|
||||||
{:error, error} -> {:error, error}
|
{:error, error} -> {:error, error}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ defmodule MyApp.Data.User do
|
|||||||
# need to add token back to map because we don't store it in the database
|
# need to add token back to map because we don't store it in the database
|
||||||
defp add_extra_params({:error, error}, _), do: {:error, error}
|
defp add_extra_params({:error, error}, _), do: {:error, error}
|
||||||
defp add_extra_params({:ok, user}, params) do
|
defp add_extra_params({:ok, user}, params) do
|
||||||
{:ok, Map.merge(user, params)}
|
{:ok, Map.merge(user, %{access_token: params["access_token"], expires_in: params["expires_in"]})}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp insert_battlenet_user(params) do
|
defp insert_battlenet_user(params) do
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ defmodule MyApp.Data.UserTest do
|
|||||||
battletag: "mgerb",
|
battletag: "mgerb",
|
||||||
id: user.id,
|
id: user.id,
|
||||||
permissions: "user",
|
permissions: "user",
|
||||||
|
expires_in: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
# call upsert again with same battletag
|
# call upsert again with same battletag
|
||||||
@@ -41,6 +42,7 @@ defmodule MyApp.Data.UserTest do
|
|||||||
battletag: "mgerb",
|
battletag: "mgerb",
|
||||||
id: user.id,
|
id: user.id,
|
||||||
permissions: "user",
|
permissions: "user",
|
||||||
|
expires_in: nil,
|
||||||
character_avatar: nil,
|
character_avatar: nil,
|
||||||
character_class: nil,
|
character_class: nil,
|
||||||
character_guild: nil,
|
character_guild: nil,
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ defmodule MyAppWeb.ReplyControllerTest do
|
|||||||
|
|
||||||
# new reply should work
|
# new reply should work
|
||||||
conn = post(new_conn, "/api/reply", %{"content" => "c", "thread_id" => thread_id})
|
conn = post(new_conn, "/api/reply", %{"content" => "c", "thread_id" => thread_id})
|
||||||
body = conn |> response(200) |> Poison.decode!
|
conn |> response(200) |> Poison.decode!
|
||||||
end
|
end
|
||||||
|
|
||||||
test "user update reply" do
|
test "user update reply" do
|
||||||
|
|||||||
Reference in New Issue
Block a user