Skip to content

Conversation

Copy link

Copilot AI commented Jan 28, 2026

Auth guard now provides wallet context to authenticated endpoints, eliminating redundant wallet lookups. Device sessions now capture the full authentication tuple (device, wallet, nonce, signature) for complete audit trails.

Changes

Enhanced VerifiedAuth

pub struct VerifiedAuth {
    pub device: DeviceRow,
    pub address: String,
    pub wallet_id: i32,           // Direct DB reference
    pub wallet_identifier: String, // e.g., "multicoin_0x123..."
}

Added nonce to devices_sessions

  • Migration adds nonce VARCHAR(256) NOT NULL
  • Complete authentication record: device + wallet + nonce + signature + timestamp

Eliminated redundant operations

  • Rewards endpoints previously recreated WalletId::Multicoin(address).id() and re-fetched wallet
  • Now use auth.wallet_id and auth.wallet_identifier directly
  • One wallet operation at auth time, reused everywhere

Code organization

  • Moved primitives::WalletType and primitives::WalletSource to top-level imports
  • Removed inline primitives:: qualifiers throughout

Example

Before:

pub async fn create_referral(request: Authenticated<ReferralCode>, ...) {
    let wallet_identifier = WalletId::Multicoin(request.auth.address.clone()).id();
    client.create_username(&wallet_identifier, ...)
}

After:

pub async fn create_referral(request: Authenticated<ReferralCode>, ...) {
    client.create_username(&request.auth.wallet_identifier, ...)
}
Original prompt

can you add devices_sessions table that will contain signsture, device id when it's used to login, see rewards logic that has a auth guard, it should contain logic there


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@semanticdiff-com
Copy link

semanticdiff-com bot commented Jan 28, 2026

Co-authored-by: gemcoder21 <104884878+gemcoder21@users.noreply.github.com>
Copilot AI changed the title [WIP] Add devices_sessions table for login signatures and device IDs Add devices_sessions table for authentication audit trail Jan 28, 2026
Copilot AI requested a review from gemcoder21 January 28, 2026 05:25
Co-authored-by: gemcoder21 <104884878+gemcoder21@users.noreply.github.com>
Copilot AI changed the title Add devices_sessions table for authentication audit trail Use wallet_id FK in devices_sessions instead of address string Jan 28, 2026
Copilot AI and others added 2 commits January 28, 2026 17:08
Co-authored-by: gemcoder21 <104884878+gemcoder21@users.noreply.github.com>
Co-authored-by: gemcoder21 <104884878+gemcoder21@users.noreply.github.com>
Copilot AI changed the title Use wallet_id FK in devices_sessions instead of address string Add wallet context to auth guard and store nonce in sessions Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants