Skip to content
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

Admission check endpoint #338

Merged
merged 8 commits into from
Jan 12, 2024
Merged

Admission check endpoint #338

merged 8 commits into from
Jan 12, 2024

Conversation

medjedovicm
Copy link
Contributor

Description

Created admission router and admission check controller which runs a check against the provided pubkey in the URL parameter and returns JSON with information if the user (pubkey) is admitted or not.

GET /admissions/check/:pubkey

Response:

{
  "userAdmitted": boolean
}

Related Issue

Closes #336

Motivation and Context

In our use case, we need to check if a user is admitted on our own relay before we let them log in.
The user is redirected to the relay page (in the new tab) while we send a check request every 10 seconds or so, so we can automatically figure out when payment is done.

How Has This Been Tested?

Visited a new endpoint in the browser, looking for the response.
As far as I am aware my changes do not affect any other parts of the code.

Screenshots (if appropriate):

image

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • All new and existing tests passed.

const pubkey = request.params.pubkey
const user = await this.userRepository.findByPubkey(pubkey)

console.log('user', user)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove

}

public async isRateLimited(request: Request, settings: Settings) {
const rateLimits = path(['limits', 'invoice', 'rateLimits'], settings)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a different rate limit for this endpoint

@cameri cameri enabled auto-merge (squash) September 9, 2023 14:42
auto-merge was automatically disabled September 12, 2023 08:23

Head branch was pushed to by a user without write access

@medjedovicm
Copy link
Contributor Author

I'm sorry, I missed a crucial commit... I think this structure makes more sense. Another commit is coming with an addressed rate limits comment.

@cameri
Copy link
Owner

cameri commented Jan 12, 2024

@medjedovicm ive fixed the integration tests, do you mind rebasing off the main branch to incorporate the fix into yours?

@medjedovicm
Copy link
Contributor Author

@cameri Yes sure, done.

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 7506254600

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.4%) to 54.41%

Totals Coverage Status
Change from base Build 7498690615: -0.4%
Covered Lines: 1309
Relevant Lines: 2357

💛 - Coveralls

@cameri cameri merged commit ed30823 into cameri:main Jan 12, 2024
9 of 10 checks passed
Copy link

🎉 This PR is included in version 2.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to easily verify if the npub has paid the invoice
3 participants