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

Support custom domain verification #9

Merged
merged 47 commits into from
Dec 15, 2023

Conversation

MarkRunWu
Copy link
Contributor

#7

@MarkRunWu MarkRunWu requested a review from kiootic December 12, 2023 07:18
internal/models/domain_verification.go Outdated Show resolved Hide resolved
Comment on lines 139 to 143
entry := middleware.GetLogEntry(r)
if entry != nil {
e := entry.(*httputil.LogEntry)
e.Logger = e.Logger.With(zap.String("site", handler.ID()))
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we should check for nil here; we assume it is always provided in context throughout the request lifecycle. We can instead provide a placeholder logger for testing purpose.

internal/db/sqlite/domain_verification.go Outdated Show resolved Hide resolved
internal/models/domain_verification_test.go Outdated Show resolved Hide resolved
internal/cron/verify_domain_ownership.go Outdated Show resolved Hide resolved
internal/cron/verify_domain_ownership.go Show resolved Hide resolved
internal/cron/verify_domain_ownership.go Outdated Show resolved Hide resolved
internal/cron/verify_domain_ownership.go Outdated Show resolved Hide resolved
.github/workflows/test.yaml Outdated Show resolved Hide resolved
@MarkRunWu
Copy link
Contributor Author

@kiootic Updated, 🙇

Here tui changes:

pageship domains --app=<app_id>

截圖 2023-12-14 下午4 48 51

pageship domains --app=<app_id> activate <domain>

截圖 2023-12-14 下午4 49 13

}
config, ok := app.Config.ResolveDomain(domainName)
if ok {
c.CreateDomain(ctx, models.NewDomain(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need check error

Comment on lines 98 to 99
c.DeleteDomain(ctx, domain.ID, now)
c.CreateDomain(ctx, models.NewDomain(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need check error

}
} else {
if domain != nil && domain.AppID == domainVerification.AppID {
c.DeleteDomain(ctx, domain.ID, now)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need check error


func (q query[T]) ScheduleDomainVerificationAt(ctx context.Context, id string, time time.Time) error {
_, err := q.ext.ExecContext(ctx, `
UPDATE domain_verification SET
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need updated at too

entry := middleware.GetLogEntry(r).(*httputil.LogEntry)
entry.Logger = entry.Logger.With(zap.String("user", authn.Subject))
entry := middleware.GetLogEntry(r)
if entry != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need check nil?

Comment on lines 97 to 102
if c.Config.DomainVerificationEnabled {
c.handleDomainVerification(w, r)
} else {
c.handleDomainCreate(w, r)
}
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we merge the two functions together?

Comment on lines 25 to 32
num1, err := rand.Int(rand.Reader, big.NewInt(999999))
if err != nil {
panic(err)
}
num2, err := rand.Int(rand.Reader, big.NewInt(999999))
if err != nil {
panic(err)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can reference RandomID function instead to use random bytes directly.

@MarkRunWu
Copy link
Contributor Author

@kiootic updated 🙇

Copy link
Collaborator

@kiootic kiootic left a comment

Choose a reason for hiding this comment

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

Thanks!

@kiootic kiootic merged commit 859784c into oursky:main Dec 15, 2023
2 checks passed
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.

2 participants