-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/rest api platform [DO NOT MERGE] #40
Conversation
…o show dashboard without signup
Ahmed/feat add middleware layer
Feature/rest api platform
Reviewer's Guide by SourceryThis pull request refactors the authentication logic to use a more secure and robust approach. It removes the dependency on the Deriv API for authentication and introduces a new login mechanism using account ID and password. The changes also include improvements to error handling and session management. Sequence diagram for the new login flowsequenceDiagram
actor User
participant LoginPage
participant AuthStore
participant AuthService
participant API
User->>LoginPage: Enter credentials
LoginPage->>AuthStore: startAuthorizing()
LoginPage->>API: POST /login
API-->>LoginPage: Return token
LoginPage->>AuthStore: handleLoginSuccess(token)
AuthStore->>AuthService: setToken(token)
AuthService->>localStorage: Store token
LoginPage->>API: GET /balance
API-->>LoginPage: Return balance
LoginPage->>User: Redirect to dashboard
Class diagram for the updated authentication systemclassDiagram
class AuthService {
-instance: AuthService
-TOKEN_KEY: string
+getInstance(): AuthService
+getStoredToken(): string
+setToken(token: string): void
+clearAuth(): void
+isAuthenticated(): boolean
}
class AuthStore {
+isAuthenticated: boolean
+isAuthorizing: boolean
+lastError: string
+handleLoginSuccess(token: string)
+handleLoginFailure(error: Error)
+startAuthorizing()
+logout()
+clearError()
}
class ApiError {
+message: string
+status: number
+code: string
}
AuthStore --> AuthService
AuthError --|> Error
NetworkError --|> ApiError
AuthenticationError --|> ApiError
TokenValidationError --|> AuthenticationError
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Manifest Filespackage-lock.json
package.json
|
✨ Preview deployment is ready! 🔗 Preview URL: https://trade-rise-fall-h2frf49dt.binary.sx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ahmed-deriv - I've reviewed your changes and found some issues that need to be addressed.
Blocking issues:
- Add token validation before storage (link)
Overall Comments:
- Consider adding JSDoc comments to document the public APIs in the service and store classes to improve maintainability
- What is the session management strategy now that the token validation check interval has been removed? Consider documenting the approach
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🔴 Security: 1 blocking issue
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Ahmed/feat add unit test
Summary by Sourcery
Implement authentication and display user balance in the header.
New Features:
Tests: