Add starter deck flow, admin force-logout + rename, shop flag
Auth chain: - auth.proto: add needs_starter_deck to Login/Register/ValidateToken responses - auth.proto: add RevokeAllSessions RPC - AuthGrpcHandler: populate NeedsStarterDeck from Account.StarterDeckSelectedAt - AuthGrpcHandler: track tokens in UserSessions Redis SET on create/logout - AuthGrpcHandler: implement RevokeAllSessions (Redis + Postgres) - IGatewayAuthValidator / GatewayAuthValidator: thread NeedsStarterDeck through tuples - ConnectionLoop: include needsStarterDeck in auth ack payload Client: - Auth.gd: store needs_starter_deck from auth reply; clear on logout - login_screen.gd: route to StarterDeckScreen when needs_starter_deck = true - scenes/starter_deck/: new StarterDeckScreen (fetch decks → pick → confirm → InitScreen) Admin panel: - AccountDetail.razor: Force Logout All Sessions card (Redis + Postgres revoke) - AccountDetail.razor: Change Display Name form with uniqueness check - SOR.Admin: add StackExchange.Redis package + DI registration - PrebuiltDeckEditor.razor: split into IsStarterDeck + IsAvailableInShop checkboxes - PrebuiltDeck.cs: add IsAvailableInShop field - Migration: AddPrebuiltDeckShopFlag Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -27,9 +27,13 @@ signal auth_failed(error_code: String, message: String)
|
|||||||
signal session_expired ## Fired when the disconnect timeout logs the user out.
|
signal session_expired ## Fired when the disconnect timeout logs the user out.
|
||||||
|
|
||||||
## Set after a successful auth. Empty while unauthenticated.
|
## Set after a successful auth. Empty while unauthenticated.
|
||||||
var user_id: String = ""
|
var user_id: String = ""
|
||||||
var display_name: String = ""
|
var display_name: String = ""
|
||||||
var session_token: String = ""
|
var session_token: String = ""
|
||||||
|
## True when the authenticated account has not yet selected a starter deck.
|
||||||
|
## Reset to false on logout. Checked by login_screen.gd to route new players
|
||||||
|
## to StarterDeckScreen instead of the normal InitScreen flow.
|
||||||
|
var needs_starter_deck: bool = false
|
||||||
|
|
||||||
## Monotonic timestamp (seconds) when the last disconnect started; -1 = connected.
|
## Monotonic timestamp (seconds) when the last disconnect started; -1 = connected.
|
||||||
var _disconnect_at: float = -1.0
|
var _disconnect_at: float = -1.0
|
||||||
@@ -77,9 +81,10 @@ func register(email: String, password: String, disp_name: String) -> void:
|
|||||||
|
|
||||||
## Clear the saved session and reset auth state.
|
## Clear the saved session and reset auth state.
|
||||||
func logout() -> void:
|
func logout() -> void:
|
||||||
user_id = ""
|
user_id = ""
|
||||||
display_name = ""
|
display_name = ""
|
||||||
session_token = ""
|
session_token = ""
|
||||||
|
needs_starter_deck = false
|
||||||
_save_session()
|
_save_session()
|
||||||
|
|
||||||
# ── Private ───────────────────────────────────────────────────────────────────
|
# ── Private ───────────────────────────────────────────────────────────────────
|
||||||
@@ -114,9 +119,10 @@ func _on_network_disconnected() -> void:
|
|||||||
|
|
||||||
func _on_auth_ok(payload: Variant) -> void:
|
func _on_auth_ok(payload: Variant) -> void:
|
||||||
var p := payload as Dictionary
|
var p := payload as Dictionary
|
||||||
user_id = p.get("userId", "")
|
user_id = p.get("userId", "")
|
||||||
display_name = p.get("displayName", "")
|
display_name = p.get("displayName", "")
|
||||||
session_token = p.get("sessionToken", "")
|
session_token = p.get("sessionToken", "")
|
||||||
|
needs_starter_deck = p.get("needsStarterDeck", false)
|
||||||
_save_session()
|
_save_session()
|
||||||
auth_success.emit(user_id, display_name)
|
auth_success.emit(user_id, display_name)
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,10 @@ func _on_auth_failed(error_code: String, message: String) -> void:
|
|||||||
# ── Helpers ───────────────────────────────────────────────────────────────────
|
# ── Helpers ───────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
func _go_to_main() -> void:
|
func _go_to_main() -> void:
|
||||||
get_tree().change_scene_to_file("res://scenes/init/InitScreen.tscn")
|
if Auth.needs_starter_deck:
|
||||||
|
get_tree().change_scene_to_file("res://scenes/starter_deck/StarterDeckScreen.tscn")
|
||||||
|
else:
|
||||||
|
get_tree().change_scene_to_file("res://scenes/init/InitScreen.tscn")
|
||||||
|
|
||||||
|
|
||||||
func _set_status(text: String, is_error: bool) -> void:
|
func _set_status(text: String, is_error: bool) -> void:
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
[gd_scene load_steps=2 format=3]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scenes/starter_deck/starter_deck_screen.gd" id="1_sds"]
|
||||||
|
|
||||||
|
[node name="StarterDeckScreen" type="Control"]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
script = ExtResource("1_sds")
|
||||||
|
|
||||||
|
[node name="Background" type="ColorRect" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
color = Color(0.094, 0.094, 0.137, 1.0)
|
||||||
|
|
||||||
|
[node name="OuterMargin" type="MarginContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
theme_override_constants/margin_left = 40
|
||||||
|
theme_override_constants/margin_right = 40
|
||||||
|
theme_override_constants/margin_top = 32
|
||||||
|
theme_override_constants/margin_bottom = 32
|
||||||
|
|
||||||
|
[node name="Layout" type="VBoxContainer" parent="OuterMargin"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 16
|
||||||
|
|
||||||
|
[node name="TitleLabel" type="Label" parent="OuterMargin/Layout"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Choose Your Starter Deck"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
theme_override_font_sizes/font_size = 28
|
||||||
|
|
||||||
|
[node name="SubLabel" type="Label" parent="OuterMargin/Layout"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Select a deck to begin your journey. This choice is permanent."
|
||||||
|
horizontal_alignment = 1
|
||||||
|
modulate = Color(0.7, 0.7, 0.8, 1.0)
|
||||||
|
theme_override_font_sizes/font_size = 13
|
||||||
|
|
||||||
|
[node name="HSeparator" type="HSeparator" parent="OuterMargin/Layout"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="StatusLabel" type="Label" parent="OuterMargin/Layout"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Loading…"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
autowrap_mode = 3
|
||||||
|
modulate = Color(0.75, 0.75, 0.8, 1.0)
|
||||||
|
theme_override_font_sizes/font_size = 13
|
||||||
|
|
||||||
|
[node name="Scroll" type="ScrollContainer" parent="OuterMargin/Layout"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
horizontal_scroll_mode = 0
|
||||||
|
|
||||||
|
[node name="DeckList" type="VBoxContainer" parent="OuterMargin/Layout/Scroll"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
theme_override_constants/separation = 10
|
||||||
|
|
||||||
|
[node name="ConfirmBtn" type="Button" parent="OuterMargin/Layout"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
custom_minimum_size = Vector2(0, 48)
|
||||||
|
text = "Choose This Deck"
|
||||||
|
disabled = true
|
||||||
|
theme_override_font_sizes/font_size = 16
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
extends Control
|
||||||
|
## Starter deck selection screen — shown to new players immediately after auth.
|
||||||
|
##
|
||||||
|
## Flow:
|
||||||
|
## 1. Send collection.get_starter_decks → populate deck list.
|
||||||
|
## 2. Player taps a deck item to select it (highlighted border).
|
||||||
|
## 3. "Choose This Deck" button becomes enabled; player confirms.
|
||||||
|
## 4. Send collection.select_starter_deck { starterDeckId }.
|
||||||
|
## 5. On success: set Auth.needs_starter_deck = false → navigate to InitScreen.
|
||||||
|
|
||||||
|
@onready var status_label : Label = %StatusLabel
|
||||||
|
@onready var deck_list : VBoxContainer = %DeckList
|
||||||
|
@onready var confirm_btn : Button = %ConfirmBtn
|
||||||
|
|
||||||
|
const SEL_COLOR := Color(0.36, 0.56, 1.0, 1.0)
|
||||||
|
const DEF_COLOR := Color(0.25, 0.25, 0.35, 1.0)
|
||||||
|
|
||||||
|
var _selected_id: String = ""
|
||||||
|
var _confirming: bool = false
|
||||||
|
|
||||||
|
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
confirm_btn.disabled = true
|
||||||
|
confirm_btn.pressed.connect(_on_confirm_pressed)
|
||||||
|
_fetch_decks()
|
||||||
|
|
||||||
|
# ── Deck fetch ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
func _fetch_decks() -> void:
|
||||||
|
status_label.text = "Loading starter decks…"
|
||||||
|
status_label.visible = true
|
||||||
|
deck_list.visible = false
|
||||||
|
|
||||||
|
Network.request(
|
||||||
|
"collection.get_starter_decks",
|
||||||
|
{},
|
||||||
|
func(_type: String, p: Variant): _on_decks_ok(p),
|
||||||
|
func(code: String, _msg: String): _on_decks_error(code)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_decks_ok(payload: Variant) -> void:
|
||||||
|
var p := payload as Dictionary
|
||||||
|
var decks := p.get("decks", []) as Array
|
||||||
|
|
||||||
|
if decks.is_empty():
|
||||||
|
status_label.text = "No starter decks are available right now. Please contact support."
|
||||||
|
return
|
||||||
|
|
||||||
|
status_label.visible = false
|
||||||
|
deck_list.visible = true
|
||||||
|
_populate_list(decks)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_decks_error(code: String) -> void:
|
||||||
|
status_label.text = "Failed to load starter decks (%s). Check your connection." % code
|
||||||
|
|
||||||
|
# ── Deck list ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
func _populate_list(decks: Array) -> void:
|
||||||
|
for child in deck_list.get_children():
|
||||||
|
child.queue_free()
|
||||||
|
|
||||||
|
for deck in decks:
|
||||||
|
var d := deck as Dictionary
|
||||||
|
var id := d.get("id", "") as String
|
||||||
|
deck_list.add_child(_build_card(d, id))
|
||||||
|
|
||||||
|
|
||||||
|
func _build_card(d: Dictionary, id: String) -> Button:
|
||||||
|
var btn := Button.new()
|
||||||
|
btn.name = "Deck_%s" % id
|
||||||
|
btn.flat = false
|
||||||
|
btn.focus_mode = Control.FOCUS_CLICK
|
||||||
|
btn.size_flags_horizontal = Control.SIZE_FILL
|
||||||
|
_apply_card_style(btn, false)
|
||||||
|
|
||||||
|
var inner := VBoxContainer.new()
|
||||||
|
inner.add_theme_constant_override("separation", 5)
|
||||||
|
btn.add_child(inner)
|
||||||
|
|
||||||
|
# Deck name
|
||||||
|
var name_lbl := Label.new()
|
||||||
|
name_lbl.text = d.get("name", "Unknown Deck")
|
||||||
|
name_lbl.add_theme_font_size_override("font_size", 16)
|
||||||
|
inner.add_child(name_lbl)
|
||||||
|
|
||||||
|
# ArchSpirit · card count
|
||||||
|
var arch : String = d.get("archSpiritName", "")
|
||||||
|
var total : int = d.get("totalCards", 0)
|
||||||
|
var sub_lbl := Label.new()
|
||||||
|
sub_lbl.text = ("%s · %d cards" % [arch, total]) if not arch.is_empty() \
|
||||||
|
else ("%d cards" % total)
|
||||||
|
sub_lbl.modulate = Color(0.7, 0.7, 0.8)
|
||||||
|
sub_lbl.add_theme_font_size_override("font_size", 12)
|
||||||
|
inner.add_child(sub_lbl)
|
||||||
|
|
||||||
|
# Optional description
|
||||||
|
var desc : String = d.get("description", "")
|
||||||
|
if not desc.is_empty():
|
||||||
|
var desc_lbl := Label.new()
|
||||||
|
desc_lbl.text = desc
|
||||||
|
desc_lbl.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||||
|
desc_lbl.modulate = Color(0.65, 0.65, 0.75)
|
||||||
|
desc_lbl.add_theme_font_size_override("font_size", 11)
|
||||||
|
inner.add_child(desc_lbl)
|
||||||
|
|
||||||
|
btn.pressed.connect(func(): _select_deck(id))
|
||||||
|
return btn
|
||||||
|
|
||||||
|
|
||||||
|
func _apply_card_style(btn: Button, selected: bool,
|
||||||
|
bg: Color = Color(0.13, 0.13, 0.20, 1.0)) -> void:
|
||||||
|
var make := func(b: Color) -> StyleBoxFlat:
|
||||||
|
var s := StyleBoxFlat.new()
|
||||||
|
s.bg_color = b
|
||||||
|
s.border_color = SEL_COLOR if selected else DEF_COLOR
|
||||||
|
s.set_border_width_all(2)
|
||||||
|
s.set_corner_radius_all(6)
|
||||||
|
s.content_margin_left = 14
|
||||||
|
s.content_margin_right = 14
|
||||||
|
s.content_margin_top = 12
|
||||||
|
s.content_margin_bottom = 12
|
||||||
|
return s
|
||||||
|
btn.add_theme_stylebox_override("normal", make.call(bg))
|
||||||
|
btn.add_theme_stylebox_override("hover", make.call(Color(0.20, 0.20, 0.30, 1.0)))
|
||||||
|
btn.add_theme_stylebox_override("pressed", make.call(bg))
|
||||||
|
btn.add_theme_stylebox_override("focus", make.call(bg))
|
||||||
|
|
||||||
|
|
||||||
|
func _select_deck(id: String) -> void:
|
||||||
|
_selected_id = id
|
||||||
|
for child in deck_list.get_children():
|
||||||
|
var btn := child as Button
|
||||||
|
if btn == null:
|
||||||
|
continue
|
||||||
|
_apply_card_style(btn, btn.name == ("Deck_%s" % id))
|
||||||
|
confirm_btn.disabled = false
|
||||||
|
|
||||||
|
# ── Confirm ───────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
func _on_confirm_pressed() -> void:
|
||||||
|
if _selected_id.is_empty() or _confirming:
|
||||||
|
return
|
||||||
|
_confirming = true
|
||||||
|
confirm_btn.disabled = true
|
||||||
|
status_label.text = "Claiming your starter deck…"
|
||||||
|
status_label.visible = true
|
||||||
|
|
||||||
|
Network.request(
|
||||||
|
"collection.select_starter_deck",
|
||||||
|
{ "starterDeckId": _selected_id },
|
||||||
|
func(_type: String, _p: Variant): _on_select_ok(),
|
||||||
|
func(code: String, msg: String): _on_select_error(code, msg)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_select_ok() -> void:
|
||||||
|
Auth.needs_starter_deck = false
|
||||||
|
get_tree().change_scene_to_file("res://scenes/init/InitScreen.tscn")
|
||||||
|
|
||||||
|
|
||||||
|
func _on_select_error(code: String, msg: String) -> void:
|
||||||
|
_confirming = false
|
||||||
|
confirm_btn.disabled = false
|
||||||
|
status_label.text = "Could not select deck (%s): %s" % [code, msg]
|
||||||
|
status_label.visible = true
|
||||||
@@ -3,7 +3,10 @@
|
|||||||
@inject SorIdentityDbContext Db
|
@inject SorIdentityDbContext Db
|
||||||
@inject UserManager<Account> UserManager
|
@inject UserManager<Account> UserManager
|
||||||
@inject NavigationManager Nav
|
@inject NavigationManager Nav
|
||||||
|
@inject IConnectionMultiplexer Redis
|
||||||
@using Microsoft.AspNetCore.Identity
|
@using Microsoft.AspNetCore.Identity
|
||||||
|
@using StackExchange.Redis
|
||||||
|
@using SOR.Shared.Redis
|
||||||
|
|
||||||
<PageTitle>Account – SOR Admin</PageTitle>
|
<PageTitle>Account – SOR Admin</PageTitle>
|
||||||
|
|
||||||
@@ -189,6 +192,49 @@ else
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Change Display Name -->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card shadow-sm">
|
||||||
|
<div class="card-header fw-medium">Change Display Name</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label small">New Display Name</label>
|
||||||
|
<input @bind="_newDisplayName" type="text" class="form-control form-control-sm"
|
||||||
|
placeholder="Unique in-game name" maxlength="32" />
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-sm btn-primary" @onclick="ChangeDisplayNameAsync">
|
||||||
|
<i class="bi bi-pencil me-1"></i>Update Display Name
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Force Logout -->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card shadow-sm border-warning">
|
||||||
|
<div class="card-header fw-medium text-warning-emphasis">Force Logout All Sessions</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p class="text-muted small mb-3">
|
||||||
|
Revokes every active session token for this account in both Redis and
|
||||||
|
the database. The player will be disconnected immediately and must log
|
||||||
|
in again on all devices.
|
||||||
|
</p>
|
||||||
|
<button class="btn btn-sm btn-outline-danger" @onclick="ForceLogoutAsync"
|
||||||
|
disabled="@_forceLoggingOut">
|
||||||
|
@if (_forceLoggingOut)
|
||||||
|
{
|
||||||
|
<span class="spinner-border spinner-border-sm me-1"></span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<i class="bi bi-box-arrow-right me-1"></i>
|
||||||
|
}
|
||||||
|
Force Logout
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,6 +253,8 @@ else
|
|||||||
|
|
||||||
private string _newPassword = "";
|
private string _newPassword = "";
|
||||||
private string _confirmPassword = "";
|
private string _confirmPassword = "";
|
||||||
|
private string _newDisplayName = "";
|
||||||
|
private bool _forceLoggingOut;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
@@ -311,4 +359,77 @@ else
|
|||||||
_isError = false;
|
_isError = false;
|
||||||
RefreshStatus();
|
RefreshStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task ChangeDisplayNameAsync()
|
||||||
|
{
|
||||||
|
if (_account == null) return;
|
||||||
|
|
||||||
|
var name = _newDisplayName.Trim();
|
||||||
|
if (string.IsNullOrEmpty(name))
|
||||||
|
{
|
||||||
|
_message = "Display name cannot be empty.";
|
||||||
|
_isError = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var taken = await UserManager.Users.AnyAsync(u => u.DisplayName == name && u.Id != _account.Id);
|
||||||
|
if (taken)
|
||||||
|
{
|
||||||
|
_message = "That display name is already taken.";
|
||||||
|
_isError = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_account.DisplayName = name;
|
||||||
|
var result = await UserManager.UpdateAsync(_account);
|
||||||
|
if (result.Succeeded)
|
||||||
|
{
|
||||||
|
_message = $"Display name changed to \"{name}\".";
|
||||||
|
_isError = false;
|
||||||
|
_newDisplayName = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_message = string.Join(" ", result.Errors.Select(e => e.Description));
|
||||||
|
_isError = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ForceLogoutAsync()
|
||||||
|
{
|
||||||
|
if (_account == null) return;
|
||||||
|
_forceLoggingOut = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var cache = Redis.GetDatabase();
|
||||||
|
var userKey = RedisKeys.UserSessions(_account.Id.ToString());
|
||||||
|
|
||||||
|
// Remove all session keys from Redis.
|
||||||
|
var members = await cache.SetMembersAsync(userKey);
|
||||||
|
foreach (var m in members)
|
||||||
|
await cache.KeyDeleteAsync(RedisKeys.Session(m!));
|
||||||
|
await cache.KeyDeleteAsync(userKey);
|
||||||
|
|
||||||
|
// Revoke all active Postgres sessions.
|
||||||
|
var now = DateTimeOffset.UtcNow;
|
||||||
|
var sessions = await Db.AccountSessions
|
||||||
|
.Where(s => s.AccountId == _account.Id && s.RevokedAt == null && s.ExpiresAt > now)
|
||||||
|
.ToListAsync();
|
||||||
|
foreach (var s in sessions)
|
||||||
|
s.RevokedAt = now;
|
||||||
|
await Db.SaveChangesAsync();
|
||||||
|
|
||||||
|
_message = $"Revoked {sessions.Count} session(s). The player has been logged out.";
|
||||||
|
_isError = false;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_message = $"Force logout failed: {ex.Message}";
|
||||||
|
_isError = true;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_forceLoggingOut = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ else
|
|||||||
class="form-control" placeholder="—" />
|
class="form-control" placeholder="—" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4 d-flex align-items-end gap-4">
|
<div class="col-md-4 d-flex flex-column gap-2 justify-content-end">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input @bind="_deck.IsActive" type="checkbox" class="form-check-input" id="chkActive" />
|
<input @bind="_deck.IsActive" type="checkbox" class="form-check-input" id="chkActive" />
|
||||||
<label class="form-check-label fw-medium" for="chkActive">Active</label>
|
<label class="form-check-label fw-medium" for="chkActive">Active</label>
|
||||||
@@ -75,7 +75,13 @@ else
|
|||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input @bind="_deck.IsStarterDeck" type="checkbox" class="form-check-input" id="chkStarter" />
|
<input @bind="_deck.IsStarterDeck" type="checkbox" class="form-check-input" id="chkStarter" />
|
||||||
<label class="form-check-label fw-medium text-warning" for="chkStarter">
|
<label class="form-check-label fw-medium text-warning" for="chkStarter">
|
||||||
<i class="bi bi-star-fill me-1"></i>Starter
|
<i class="bi bi-star-fill me-1"></i>Offered to new accounts
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input @bind="_deck.IsAvailableInShop" type="checkbox" class="form-check-input" id="chkShop" />
|
||||||
|
<label class="form-check-label fw-medium text-info" for="chkShop">
|
||||||
|
<i class="bi bi-shop me-1"></i>Available in shop
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Components.Authorization;
|
using Microsoft.AspNetCore.Components.Authorization;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using StackExchange.Redis;
|
||||||
using SOR.Admin;
|
using SOR.Admin;
|
||||||
using SOR.Admin.Components;
|
using SOR.Admin.Components;
|
||||||
using SOR.Cdn;
|
using SOR.Cdn;
|
||||||
@@ -71,6 +72,11 @@ builder.Services.AddIdentityCore<Account>(options =>
|
|||||||
// ── Razor Pages (used for login/logout form posts) ─────────────────────────
|
// ── Razor Pages (used for login/logout form posts) ─────────────────────────
|
||||||
builder.Services.AddRazorPages();
|
builder.Services.AddRazorPages();
|
||||||
|
|
||||||
|
// ── Redis ──────────────────────────────────────────────────────────────────
|
||||||
|
builder.Services.AddSingleton<IConnectionMultiplexer>(_ =>
|
||||||
|
ConnectionMultiplexer.Connect(
|
||||||
|
builder.Configuration.GetConnectionString("Redis") ?? "localhost:6379"));
|
||||||
|
|
||||||
// ── CDN client ────────────────────────────────────────────────────────────
|
// ── CDN client ────────────────────────────────────────────────────────────
|
||||||
builder.Services.AddCdnClient(builder.Configuration);
|
builder.Services.AddCdnClient(builder.Configuration);
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
||||||
|
<PackageReference Include="StackExchange.Redis" />
|
||||||
|
|
||||||
<ProjectReference Include="..\SOR.Cdn\SOR.Cdn.csproj" />
|
<ProjectReference Include="..\SOR.Cdn\SOR.Cdn.csproj" />
|
||||||
<ProjectReference Include="..\SOR.Database\SOR.Database.csproj" />
|
<ProjectReference Include="..\SOR.Database\SOR.Database.csproj" />
|
||||||
<ProjectReference Include="..\SOR.Shared\SOR.Shared.csproj" />
|
<ProjectReference Include="..\SOR.Shared\SOR.Shared.csproj" />
|
||||||
|
|||||||
@@ -74,7 +74,12 @@ public sealed class AuthGrpcHandler : AuthService.AuthServiceBase
|
|||||||
|
|
||||||
var token = await CreateSessionAsync(user.Id, context);
|
var token = await CreateSessionAsync(user.Id, context);
|
||||||
_logger.LogInformation("Login succeeded for account {AccountId}", user.Id);
|
_logger.LogInformation("Login succeeded for account {AccountId}", user.Id);
|
||||||
return new LoginResponse { Success = true, SessionToken = token };
|
return new LoginResponse
|
||||||
|
{
|
||||||
|
Success = true,
|
||||||
|
SessionToken = token,
|
||||||
|
NeedsStarterDeck = !user.StarterDeckSelectedAt.HasValue,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Register ──────────────────────────────────────────────────────────────
|
// ── Register ──────────────────────────────────────────────────────────────
|
||||||
@@ -108,7 +113,12 @@ public sealed class AuthGrpcHandler : AuthService.AuthServiceBase
|
|||||||
|
|
||||||
var token = await CreateSessionAsync(account.Id, context);
|
var token = await CreateSessionAsync(account.Id, context);
|
||||||
_logger.LogInformation("Registered new account {AccountId}", account.Id);
|
_logger.LogInformation("Registered new account {AccountId}", account.Id);
|
||||||
return new RegisterResponse { Success = true, SessionToken = token };
|
return new RegisterResponse
|
||||||
|
{
|
||||||
|
Success = true,
|
||||||
|
SessionToken = token,
|
||||||
|
NeedsStarterDeck = true, // new accounts always need to select a starter deck
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── ValidateToken ─────────────────────────────────────────────────────────
|
// ── ValidateToken ─────────────────────────────────────────────────────────
|
||||||
@@ -129,9 +139,10 @@ public sealed class AuthGrpcHandler : AuthService.AuthServiceBase
|
|||||||
if (cached is not null)
|
if (cached is not null)
|
||||||
return new ValidateTokenResponse
|
return new ValidateTokenResponse
|
||||||
{
|
{
|
||||||
Valid = true,
|
Valid = true,
|
||||||
UserId = cached.Id.ToString(),
|
UserId = cached.Id.ToString(),
|
||||||
DisplayName = cached.DisplayName ?? string.Empty,
|
DisplayName = cached.DisplayName ?? string.Empty,
|
||||||
|
NeedsStarterDeck = !cached.StarterDeckSelectedAt.HasValue,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,9 +171,10 @@ public sealed class AuthGrpcHandler : AuthService.AuthServiceBase
|
|||||||
|
|
||||||
return new ValidateTokenResponse
|
return new ValidateTokenResponse
|
||||||
{
|
{
|
||||||
Valid = true,
|
Valid = true,
|
||||||
UserId = account.Id.ToString(),
|
UserId = account.Id.ToString(),
|
||||||
DisplayName = account.DisplayName ?? string.Empty,
|
DisplayName = account.DisplayName ?? string.Empty,
|
||||||
|
NeedsStarterDeck = !account.StarterDeckSelectedAt.HasValue,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,6 +193,10 @@ public sealed class AuthGrpcHandler : AuthService.AuthServiceBase
|
|||||||
{
|
{
|
||||||
session.RevokedAt = DateTimeOffset.UtcNow;
|
session.RevokedAt = DateTimeOffset.UtcNow;
|
||||||
await _db.SaveChangesAsync();
|
await _db.SaveChangesAsync();
|
||||||
|
var cache2 = _redis.GetDatabase();
|
||||||
|
await cache2.SetRemoveAsync(
|
||||||
|
RedisKeys.UserSessions(session.AccountId.ToString()),
|
||||||
|
request.SessionToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _redis.GetDatabase().KeyDeleteAsync(RedisKeys.Session(request.SessionToken));
|
await _redis.GetDatabase().KeyDeleteAsync(RedisKeys.Session(request.SessionToken));
|
||||||
@@ -188,6 +204,39 @@ public sealed class AuthGrpcHandler : AuthService.AuthServiceBase
|
|||||||
return new LogoutResponse();
|
return new LogoutResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── RevokeAllSessions ─────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
public override async Task<RevokeAllSessionsResponse> RevokeAllSessions(
|
||||||
|
RevokeAllSessionsRequest request, ServerCallContext context)
|
||||||
|
{
|
||||||
|
if (!Guid.TryParse(request.AccountId, out var accountId))
|
||||||
|
return new RevokeAllSessionsResponse { SessionsRevoked = 0 };
|
||||||
|
|
||||||
|
var now = DateTimeOffset.UtcNow;
|
||||||
|
var cache = _redis.GetDatabase();
|
||||||
|
var userKey = RedisKeys.UserSessions(accountId.ToString());
|
||||||
|
|
||||||
|
// Grab all raw tokens from the Redis SET, then delete each session key.
|
||||||
|
var members = await cache.SetMembersAsync(userKey);
|
||||||
|
foreach (var member in members)
|
||||||
|
await cache.KeyDeleteAsync(RedisKeys.Session(member!));
|
||||||
|
await cache.KeyDeleteAsync(userKey);
|
||||||
|
|
||||||
|
// Revoke all active Postgres sessions for this account.
|
||||||
|
var sessions = await _db.AccountSessions
|
||||||
|
.Where(s => s.AccountId == accountId && s.RevokedAt == null && s.ExpiresAt > now)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
foreach (var s in sessions)
|
||||||
|
s.RevokedAt = now;
|
||||||
|
|
||||||
|
await _db.SaveChangesAsync();
|
||||||
|
|
||||||
|
_logger.LogInformation("Revoked {Count} sessions for account {AccountId}",
|
||||||
|
sessions.Count, accountId);
|
||||||
|
return new RevokeAllSessionsResponse { SessionsRevoked = sessions.Count };
|
||||||
|
}
|
||||||
|
|
||||||
// ── Account Properties ────────────────────────────────────────────────────
|
// ── Account Properties ────────────────────────────────────────────────────
|
||||||
|
|
||||||
public override async Task<GetAccountPropertyResponse> GetAccountProperty(
|
public override async Task<GetAccountPropertyResponse> GetAccountProperty(
|
||||||
@@ -322,10 +371,10 @@ public sealed class AuthGrpcHandler : AuthService.AuthServiceBase
|
|||||||
});
|
});
|
||||||
await _db.SaveChangesAsync();
|
await _db.SaveChangesAsync();
|
||||||
|
|
||||||
await _redis.GetDatabase().StringSetAsync(
|
var ttl = expiry - DateTimeOffset.UtcNow;
|
||||||
RedisKeys.Session(token),
|
var cache = _redis.GetDatabase();
|
||||||
accountId.ToString(),
|
await cache.StringSetAsync(RedisKeys.Session(token), accountId.ToString(), ttl);
|
||||||
expiry - DateTimeOffset.UtcNow);
|
await cache.SetAddAsync(RedisKeys.UserSessions(accountId.ToString()), token);
|
||||||
|
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,12 @@ public sealed class PrebuiltDeck
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsStarterDeck { get; set; }
|
public bool IsStarterDeck { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When true this deck is purchasable in the Bazaar shop (in addition to or instead
|
||||||
|
/// of the starter-deck flow). A deck may have both flags set simultaneously.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsAvailableInShop { get; set; }
|
||||||
|
|
||||||
/// <summary>Cross-schema: the ArchSpirit card included in this deck. Bare Guid.</summary>
|
/// <summary>Cross-schema: the ArchSpirit card included in this deck. Bare Guid.</summary>
|
||||||
public Guid? ArchSpiritCardDefinitionId { get; set; }
|
public Guid? ArchSpiritCardDefinitionId { get; set; }
|
||||||
|
|
||||||
|
|||||||
Generated
+481
@@ -0,0 +1,481 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using SOR.Database.Contexts;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SOR.Database.Migrations.Bazaar
|
||||||
|
{
|
||||||
|
[DbContext(typeof(BazaarDbContext))]
|
||||||
|
[Migration("20260228175431_AddPrebuiltDeckShopFlag")]
|
||||||
|
partial class AddPrebuiltDeckShopFlag
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasDefaultSchema("bazaar")
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.0")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Bazaar.AuctionBid", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<decimal>("Amount")
|
||||||
|
.HasColumnType("numeric(18,4)");
|
||||||
|
|
||||||
|
b.Property<Guid>("BidderAccountId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Currency")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("IsWinning")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<Guid>("ListingId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("PlacedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("BidderAccountId");
|
||||||
|
|
||||||
|
b.HasIndex("ListingId", "Amount");
|
||||||
|
|
||||||
|
b.HasIndex("ListingId", "IsWinning");
|
||||||
|
|
||||||
|
b.ToTable("auction_bids", "bazaar");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarListing", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("CardDefinitionId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Currency")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("ExpiresAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<bool>("IsMasked")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("ListedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("ListingType")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("PlayerCardId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<decimal>("Price")
|
||||||
|
.HasColumnType("numeric(18,4)");
|
||||||
|
|
||||||
|
b.Property<Guid>("SellerAccountId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Status")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("SellerAccountId");
|
||||||
|
|
||||||
|
b.HasIndex("Status", "CardDefinitionId");
|
||||||
|
|
||||||
|
b.HasIndex("Status", "ExpiresAt");
|
||||||
|
|
||||||
|
b.ToTable("listings", "bazaar");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarTransaction", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<decimal>("Amount")
|
||||||
|
.HasColumnType("numeric(18,4)");
|
||||||
|
|
||||||
|
b.Property<Guid>("BuyerAccountId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Currency")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("ListingId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("PlayerCardId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("SellerAccountId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("TransactedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("BuyerAccountId");
|
||||||
|
|
||||||
|
b.HasIndex("ListingId");
|
||||||
|
|
||||||
|
b.HasIndex("SellerAccountId");
|
||||||
|
|
||||||
|
b.HasIndex("TransactedAt");
|
||||||
|
|
||||||
|
b.ToTable("transactions", "bazaar");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Bazaar.BoosterPack", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("AvailableFrom")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("AvailableUntil")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid?>("CardSetId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageCdnUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("IsActive")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(200)
|
||||||
|
.HasColumnType("character varying(200)");
|
||||||
|
|
||||||
|
b.Property<int>("OriginPointPrice")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("SlotsJson")
|
||||||
|
.HasColumnType("jsonb");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("UpdatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<decimal?>("UsdPrice")
|
||||||
|
.HasColumnType("numeric(10,2)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("IsActive");
|
||||||
|
|
||||||
|
b.HasIndex("AvailableFrom", "AvailableUntil");
|
||||||
|
|
||||||
|
b.ToTable("booster_packs", "bazaar");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Bazaar.BoosterPackCardGrant", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("CardDefinitionId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("CardName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("IsFoil")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<Guid>("PlayerCardId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("PurchaseRecordId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Rarity")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("PlayerCardId");
|
||||||
|
|
||||||
|
b.HasIndex("PurchaseRecordId");
|
||||||
|
|
||||||
|
b.ToTable("booster_pack_card_grants", "bazaar");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Bazaar.Cosmetic", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("AssetCdnUrl")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid?>("CardDefinitionId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("CosmeticType")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("IsActive")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(200)
|
||||||
|
.HasColumnType("character varying(200)");
|
||||||
|
|
||||||
|
b.Property<int>("OriginPointPrice")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("PreviewImageCdnUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("UpdatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<decimal?>("UsdPrice")
|
||||||
|
.HasColumnType("numeric(10,2)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CardDefinitionId");
|
||||||
|
|
||||||
|
b.HasIndex("CosmeticType", "IsActive");
|
||||||
|
|
||||||
|
b.ToTable("cosmetics", "bazaar");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Bazaar.PrebuiltDeck", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid?>("ArchSpiritCardDefinitionId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("ArchSpiritName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("AvailableFrom")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("AvailableUntil")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageCdnUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("IsActive")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("IsAvailableInShop")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("IsStarterDeck")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(200)
|
||||||
|
.HasColumnType("character varying(200)");
|
||||||
|
|
||||||
|
b.Property<int>("OriginPointPrice")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("UpdatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<decimal?>("UsdPrice")
|
||||||
|
.HasColumnType("numeric(10,2)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("IsActive");
|
||||||
|
|
||||||
|
b.HasIndex("IsStarterDeck");
|
||||||
|
|
||||||
|
b.ToTable("prebuilt_decks", "bazaar");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Bazaar.PrebuiltDeckCard", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("CardDefinitionId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("CardName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(200)
|
||||||
|
.HasColumnType("character varying(200)");
|
||||||
|
|
||||||
|
b.Property<Guid>("PrebuiltDeckId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("Quantity")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("PrebuiltDeckId", "CardDefinitionId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("prebuilt_deck_cards", "bazaar");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Bazaar.PurchaseRecord", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("AccountId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("OriginPointsSpent")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<Guid?>("ProductId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("ProductType")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("PurchasedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<int>("QuantityGranted")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<decimal?>("UsdSpent")
|
||||||
|
.HasColumnType("numeric(10,2)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AccountId", "PurchasedAt");
|
||||||
|
|
||||||
|
b.HasIndex("ProductType", "PurchasedAt");
|
||||||
|
|
||||||
|
b.ToTable("purchase_records", "bazaar");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Bazaar.AuctionBid", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SOR.Database.Entities.Bazaar.BazaarListing", "Listing")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ListingId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Listing");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarTransaction", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SOR.Database.Entities.Bazaar.BazaarListing", "Listing")
|
||||||
|
.WithMany("Transactions")
|
||||||
|
.HasForeignKey("ListingId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Listing");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Bazaar.BoosterPackCardGrant", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SOR.Database.Entities.Bazaar.PurchaseRecord", "PurchaseRecord")
|
||||||
|
.WithMany("CardGrants")
|
||||||
|
.HasForeignKey("PurchaseRecordId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("PurchaseRecord");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Bazaar.PrebuiltDeckCard", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SOR.Database.Entities.Bazaar.PrebuiltDeck", "PrebuiltDeck")
|
||||||
|
.WithMany("Cards")
|
||||||
|
.HasForeignKey("PrebuiltDeckId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("PrebuiltDeck");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarListing", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Transactions");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Bazaar.PrebuiltDeck", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Cards");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SOR.Database.Entities.Bazaar.PurchaseRecord", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("CardGrants");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SOR.Database.Migrations.Bazaar
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddPrebuiltDeckShopFlag : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "IsAvailableInShop",
|
||||||
|
schema: "bazaar",
|
||||||
|
table: "prebuilt_decks",
|
||||||
|
type: "boolean",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "IsAvailableInShop",
|
||||||
|
schema: "bazaar",
|
||||||
|
table: "prebuilt_decks");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -320,6 +320,9 @@ namespace SOR.Database.Migrations.Bazaar
|
|||||||
b.Property<bool>("IsActive")
|
b.Property<bool>("IsActive")
|
||||||
.HasColumnType("boolean");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("IsAvailableInShop")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<bool>("IsStarterDeck")
|
b.Property<bool>("IsStarterDeck")
|
||||||
.HasColumnType("boolean");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public sealed class GatewayAuthValidator : IGatewayAuthValidator
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<(bool Valid, string UserId, string DisplayName)> ValidateAsync(
|
public async Task<(bool Valid, string UserId, string DisplayName, bool NeedsStarterDeck)> ValidateAsync(
|
||||||
string sessionToken,
|
string sessionToken,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
@@ -42,21 +42,21 @@ public sealed class GatewayAuthValidator : IGatewayAuthValidator
|
|||||||
if (!response.Valid)
|
if (!response.Valid)
|
||||||
{
|
{
|
||||||
_logger.LogDebug("Token validation failed: token is invalid or expired");
|
_logger.LogDebug("Token validation failed: token is invalid or expired");
|
||||||
return (false, string.Empty, string.Empty);
|
return (false, string.Empty, string.Empty, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (true, response.UserId, response.DisplayName);
|
return (true, response.UserId, response.DisplayName, response.NeedsStarterDeck);
|
||||||
}
|
}
|
||||||
catch (Grpc.Core.RpcException ex)
|
catch (Grpc.Core.RpcException ex)
|
||||||
{
|
{
|
||||||
_logger.LogWarning(ex,
|
_logger.LogWarning(ex,
|
||||||
"Auth gRPC call failed during token validation: {Status}", ex.Status.StatusCode);
|
"Auth gRPC call failed during token validation: {Status}", ex.Status.StatusCode);
|
||||||
return (false, string.Empty, string.Empty);
|
return (false, string.Empty, string.Empty, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<(bool Success, string ErrorCode, string SessionToken, string UserId, string DisplayName)>
|
public async Task<(bool Success, string ErrorCode, string SessionToken, string UserId, string DisplayName, bool NeedsStarterDeck)>
|
||||||
LoginAsync(string email, string password, CancellationToken cancellationToken = default)
|
LoginAsync(string email, string password, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -66,21 +66,21 @@ public sealed class GatewayAuthValidator : IGatewayAuthValidator
|
|||||||
cancellationToken: cancellationToken);
|
cancellationToken: cancellationToken);
|
||||||
|
|
||||||
if (!response.Success)
|
if (!response.Success)
|
||||||
return (false, response.ErrorCode, string.Empty, string.Empty, string.Empty);
|
return (false, response.ErrorCode, string.Empty, string.Empty, string.Empty, false);
|
||||||
|
|
||||||
// Token is returned; fetch display name via ValidateToken (it includes it).
|
// Token is returned; fetch display name + starter-deck flag via ValidateToken.
|
||||||
var validate = await ValidateAsync(response.SessionToken, cancellationToken);
|
var validate = await ValidateAsync(response.SessionToken, cancellationToken);
|
||||||
return (true, string.Empty, response.SessionToken, validate.UserId, validate.DisplayName);
|
return (true, string.Empty, response.SessionToken, validate.UserId, validate.DisplayName, validate.NeedsStarterDeck);
|
||||||
}
|
}
|
||||||
catch (Grpc.Core.RpcException ex)
|
catch (Grpc.Core.RpcException ex)
|
||||||
{
|
{
|
||||||
_logger.LogWarning(ex, "Auth gRPC call failed during login: {Status}", ex.Status.StatusCode);
|
_logger.LogWarning(ex, "Auth gRPC call failed during login: {Status}", ex.Status.StatusCode);
|
||||||
return (false, "AUTH_SERVICE_UNAVAILABLE", string.Empty, string.Empty, string.Empty);
|
return (false, "AUTH_SERVICE_UNAVAILABLE", string.Empty, string.Empty, string.Empty, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<(bool Success, string ErrorCode, string SessionToken, string UserId, string DisplayName)>
|
public async Task<(bool Success, string ErrorCode, string SessionToken, string UserId, string DisplayName, bool NeedsStarterDeck)>
|
||||||
RegisterAsync(string email, string password, string displayName, CancellationToken cancellationToken = default)
|
RegisterAsync(string email, string password, string displayName, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -90,15 +90,15 @@ public sealed class GatewayAuthValidator : IGatewayAuthValidator
|
|||||||
cancellationToken: cancellationToken);
|
cancellationToken: cancellationToken);
|
||||||
|
|
||||||
if (!response.Success)
|
if (!response.Success)
|
||||||
return (false, response.ErrorCode, string.Empty, string.Empty, string.Empty);
|
return (false, response.ErrorCode, string.Empty, string.Empty, string.Empty, false);
|
||||||
|
|
||||||
var validate = await ValidateAsync(response.SessionToken, cancellationToken);
|
var validate = await ValidateAsync(response.SessionToken, cancellationToken);
|
||||||
return (true, string.Empty, response.SessionToken, validate.UserId, validate.DisplayName);
|
return (true, string.Empty, response.SessionToken, validate.UserId, validate.DisplayName, validate.NeedsStarterDeck);
|
||||||
}
|
}
|
||||||
catch (Grpc.Core.RpcException ex)
|
catch (Grpc.Core.RpcException ex)
|
||||||
{
|
{
|
||||||
_logger.LogWarning(ex, "Auth gRPC call failed during register: {Status}", ex.Status.StatusCode);
|
_logger.LogWarning(ex, "Auth gRPC call failed during register: {Status}", ex.Status.StatusCode);
|
||||||
return (false, "AUTH_SERVICE_UNAVAILABLE", string.Empty, string.Empty, string.Empty);
|
return (false, "AUTH_SERVICE_UNAVAILABLE", string.Empty, string.Empty, string.Empty, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public interface IGatewayAuthValidator
|
|||||||
/// Validates an existing session token.
|
/// Validates an existing session token.
|
||||||
/// Returns (Valid=false, …) on invalid/expired token or Auth service error.
|
/// Returns (Valid=false, …) on invalid/expired token or Auth service error.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task<(bool Valid, string UserId, string DisplayName)> ValidateAsync(
|
Task<(bool Valid, string UserId, string DisplayName, bool NeedsStarterDeck)> ValidateAsync(
|
||||||
string sessionToken,
|
string sessionToken,
|
||||||
CancellationToken cancellationToken = default);
|
CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
@@ -25,13 +25,13 @@ public interface IGatewayAuthValidator
|
|||||||
/// Authenticates with email + password. Returns the new session token on success.
|
/// Authenticates with email + password. Returns the new session token on success.
|
||||||
/// ErrorCode is set (and SessionToken is empty) on failure.
|
/// ErrorCode is set (and SessionToken is empty) on failure.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task<(bool Success, string ErrorCode, string SessionToken, string UserId, string DisplayName)>
|
Task<(bool Success, string ErrorCode, string SessionToken, string UserId, string DisplayName, bool NeedsStarterDeck)>
|
||||||
LoginAsync(string email, string password, CancellationToken cancellationToken = default);
|
LoginAsync(string email, string password, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers a new account. Returns the new session token on success.
|
/// Registers a new account. Returns the new session token on success.
|
||||||
/// ErrorCode is set (and SessionToken is empty) on failure.
|
/// ErrorCode is set (and SessionToken is empty) on failure.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task<(bool Success, string ErrorCode, string SessionToken, string UserId, string DisplayName)>
|
Task<(bool Success, string ErrorCode, string SessionToken, string UserId, string DisplayName, bool NeedsStarterDeck)>
|
||||||
RegisterAsync(string email, string password, string displayName, CancellationToken cancellationToken = default);
|
RegisterAsync(string email, string password, string displayName, CancellationToken cancellationToken = default);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ public sealed class ConnectionLoop
|
|||||||
string userId;
|
string userId;
|
||||||
string displayName;
|
string displayName;
|
||||||
string ackType;
|
string ackType;
|
||||||
|
bool needsStarterDeck;
|
||||||
|
|
||||||
switch (parsedMsg.Type.ToLowerInvariant())
|
switch (parsedMsg.Type.ToLowerInvariant())
|
||||||
{
|
{
|
||||||
@@ -113,7 +114,7 @@ public sealed class ConnectionLoop
|
|||||||
try { payload = _serializer.DeserializePayload<AuthHelloPayload>(parsedMsg.Payload); }
|
try { payload = _serializer.DeserializePayload<AuthHelloPayload>(parsedMsg.Payload); }
|
||||||
catch { await RejectAsync(rawConnection, parsedMsg.Seq, "INVALID_PAYLOAD", "auth.hello payload is malformed.", appCancellationToken); return; }
|
catch { await RejectAsync(rawConnection, parsedMsg.Seq, "INVALID_PAYLOAD", "auth.hello payload is malformed.", appCancellationToken); return; }
|
||||||
|
|
||||||
var (valid, uid, dname) =
|
var (valid, uid, dname, nsd) =
|
||||||
await _authValidator.ValidateAsync(payload.SessionToken, appCancellationToken);
|
await _authValidator.ValidateAsync(payload.SessionToken, appCancellationToken);
|
||||||
if (!valid)
|
if (!valid)
|
||||||
{
|
{
|
||||||
@@ -121,8 +122,8 @@ public sealed class ConnectionLoop
|
|||||||
"AUTH_FAILED", "Invalid or expired session token.", appCancellationToken);
|
"AUTH_FAILED", "Invalid or expired session token.", appCancellationToken);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(sessionToken, userId, displayName, ackType) =
|
(sessionToken, userId, displayName, ackType, needsStarterDeck) =
|
||||||
(payload.SessionToken, uid, dname, "auth.hello.ack");
|
(payload.SessionToken, uid, dname, "auth.hello.ack", nsd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,15 +133,15 @@ public sealed class ConnectionLoop
|
|||||||
try { payload = _serializer.DeserializePayload<AuthLoginPayload>(parsedMsg.Payload); }
|
try { payload = _serializer.DeserializePayload<AuthLoginPayload>(parsedMsg.Payload); }
|
||||||
catch { await RejectAsync(rawConnection, parsedMsg.Seq, "INVALID_PAYLOAD", "auth.login payload is malformed.", appCancellationToken); return; }
|
catch { await RejectAsync(rawConnection, parsedMsg.Seq, "INVALID_PAYLOAD", "auth.login payload is malformed.", appCancellationToken); return; }
|
||||||
|
|
||||||
var (success, errorCode, token, uid, dname) =
|
var (success, errorCode, token, uid, dname, nsd) =
|
||||||
await _authValidator.LoginAsync(payload.Email, payload.Password, appCancellationToken);
|
await _authValidator.LoginAsync(payload.Email, payload.Password, appCancellationToken);
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
await RejectAsync(rawConnection, parsedMsg.Seq, errorCode, "Login failed.", appCancellationToken);
|
await RejectAsync(rawConnection, parsedMsg.Seq, errorCode, "Login failed.", appCancellationToken);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(sessionToken, userId, displayName, ackType) =
|
(sessionToken, userId, displayName, ackType, needsStarterDeck) =
|
||||||
(token, uid, dname, "auth.login.ack");
|
(token, uid, dname, "auth.login.ack", nsd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +151,7 @@ public sealed class ConnectionLoop
|
|||||||
try { payload = _serializer.DeserializePayload<AuthRegisterPayload>(parsedMsg.Payload); }
|
try { payload = _serializer.DeserializePayload<AuthRegisterPayload>(parsedMsg.Payload); }
|
||||||
catch { await RejectAsync(rawConnection, parsedMsg.Seq, "INVALID_PAYLOAD", "auth.register payload is malformed.", appCancellationToken); return; }
|
catch { await RejectAsync(rawConnection, parsedMsg.Seq, "INVALID_PAYLOAD", "auth.register payload is malformed.", appCancellationToken); return; }
|
||||||
|
|
||||||
var (success, errorCode, token, uid, dname) =
|
var (success, errorCode, token, uid, dname, nsd) =
|
||||||
await _authValidator.RegisterAsync(
|
await _authValidator.RegisterAsync(
|
||||||
payload.Email, payload.Password, payload.DisplayName, appCancellationToken);
|
payload.Email, payload.Password, payload.DisplayName, appCancellationToken);
|
||||||
if (!success)
|
if (!success)
|
||||||
@@ -158,8 +159,8 @@ public sealed class ConnectionLoop
|
|||||||
await RejectAsync(rawConnection, parsedMsg.Seq, errorCode, "Registration failed.", appCancellationToken);
|
await RejectAsync(rawConnection, parsedMsg.Seq, errorCode, "Registration failed.", appCancellationToken);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(sessionToken, userId, displayName, ackType) =
|
(sessionToken, userId, displayName, ackType, needsStarterDeck) =
|
||||||
(token, uid, dname, "auth.register.ack");
|
(token, uid, dname, "auth.register.ack", nsd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,9 +184,10 @@ public sealed class ConnectionLoop
|
|||||||
parsedMsg.Type, userId, displayName, rawConnection.ConnectionId);
|
parsedMsg.Type, userId, displayName, rawConnection.ConnectionId);
|
||||||
|
|
||||||
// Ack includes sessionToken so the client can persist it after login/register.
|
// Ack includes sessionToken so the client can persist it after login/register.
|
||||||
|
// needsStarterDeck tells the client to route new players to the deck-selection screen.
|
||||||
await SendMessageAsync(
|
await SendMessageAsync(
|
||||||
rawConnection,
|
rawConnection,
|
||||||
ServerMessage.Reply(ackType, parsedMsg.Seq, new { userId, displayName, sessionToken }),
|
ServerMessage.Reply(ackType, parsedMsg.Seq, new { userId, displayName, sessionToken, needsStarterDeck }),
|
||||||
appCancellationToken);
|
appCancellationToken);
|
||||||
|
|
||||||
// ── Phase 4: Subscribe to Redis Push Channel ───────────────────────────
|
// ── Phase 4: Subscribe to Redis Push Channel ───────────────────────────
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ message LoginResponse {
|
|||||||
string session_token = 2;
|
string session_token = 2;
|
||||||
// Failure codes: USER_NOT_FOUND | INVALID_PASSWORD | ACCOUNT_BANNED | ACCOUNT_LOCKED
|
// Failure codes: USER_NOT_FOUND | INVALID_PASSWORD | ACCOUNT_BANNED | ACCOUNT_LOCKED
|
||||||
string error_code = 3;
|
string error_code = 3;
|
||||||
|
// True when the account has never selected a starter deck (StarterDeckSelectedAt is null).
|
||||||
|
bool needs_starter_deck = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Token Validation ──────────────────────────────────────────────────────────
|
// ── Token Validation ──────────────────────────────────────────────────────────
|
||||||
@@ -29,6 +31,8 @@ message ValidateTokenResponse {
|
|||||||
// Only populated when valid = true.
|
// Only populated when valid = true.
|
||||||
string user_id = 2;
|
string user_id = 2;
|
||||||
string display_name = 3;
|
string display_name = 3;
|
||||||
|
// True when the account has never selected a starter deck.
|
||||||
|
bool needs_starter_deck = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Registration ──────────────────────────────────────────────────────────────
|
// ── Registration ──────────────────────────────────────────────────────────────
|
||||||
@@ -44,6 +48,8 @@ message RegisterResponse {
|
|||||||
string session_token = 2;
|
string session_token = 2;
|
||||||
// Failure codes: EMAIL_TAKEN | DISPLAY_NAME_TAKEN | WEAK_PASSWORD | REGISTRATION_FAILED
|
// Failure codes: EMAIL_TAKEN | DISPLAY_NAME_TAKEN | WEAK_PASSWORD | REGISTRATION_FAILED
|
||||||
string error_code = 3;
|
string error_code = 3;
|
||||||
|
// Always true for new accounts — they have never selected a starter deck.
|
||||||
|
bool needs_starter_deck = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Logout ────────────────────────────────────────────────────────────────────
|
// ── Logout ────────────────────────────────────────────────────────────────────
|
||||||
@@ -55,6 +61,18 @@ message LogoutRequest {
|
|||||||
// Empty response — logout always succeeds (idempotent; revoking a non-existent token is fine).
|
// Empty response — logout always succeeds (idempotent; revoking a non-existent token is fine).
|
||||||
message LogoutResponse {}
|
message LogoutResponse {}
|
||||||
|
|
||||||
|
// ── Admin: Revoke all sessions ─────────────────────────────────────────────────
|
||||||
|
// Forces a user off all devices by revoking every active session.
|
||||||
|
// Used by Admin Portal for force-logout actions.
|
||||||
|
|
||||||
|
message RevokeAllSessionsRequest {
|
||||||
|
string account_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RevokeAllSessionsResponse {
|
||||||
|
int32 sessions_revoked = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// ── Account Properties ────────────────────────────────────────────────────────
|
// ── Account Properties ────────────────────────────────────────────────────────
|
||||||
// Flexible key-value bag per account.
|
// Flexible key-value bag per account.
|
||||||
// Keys are snake_case strings; values are always strings (caller interprets type).
|
// Keys are snake_case strings; values are always strings (caller interprets type).
|
||||||
@@ -144,6 +162,9 @@ service AuthService {
|
|||||||
// Revoke a session token (idempotent — revoking a non-existent token is fine).
|
// Revoke a session token (idempotent — revoking a non-existent token is fine).
|
||||||
rpc Logout(LogoutRequest) returns (LogoutResponse);
|
rpc Logout(LogoutRequest) returns (LogoutResponse);
|
||||||
|
|
||||||
|
// Revoke ALL active sessions for an account (admin force-logout).
|
||||||
|
rpc RevokeAllSessions(RevokeAllSessionsRequest) returns (RevokeAllSessionsResponse);
|
||||||
|
|
||||||
// Per-account key-value property bag.
|
// Per-account key-value property bag.
|
||||||
rpc GetAccountProperty(GetAccountPropertyRequest) returns (GetAccountPropertyResponse);
|
rpc GetAccountProperty(GetAccountPropertyRequest) returns (GetAccountPropertyResponse);
|
||||||
rpc SetAccountProperty(SetAccountPropertyRequest) returns (SetAccountPropertyResponse);
|
rpc SetAccountProperty(SetAccountPropertyRequest) returns (SetAccountPropertyResponse);
|
||||||
|
|||||||
Reference in New Issue
Block a user