-
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
Support custom domain verification #9
Conversation
be0af3b
to
9500515
Compare
9500515
to
2954682
Compare
internal/handler/site/handler.go
Outdated
entry := middleware.GetLogEntry(r) | ||
if entry != nil { | ||
e := entry.(*httputil.LogEntry) | ||
e.Logger = e.Logger.With(zap.String("site", handler.ID())) | ||
} |
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.
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.
05051e7
to
c8685fb
Compare
c8685fb
to
6370bb7
Compare
@kiootic Updated, 🙇 Here tui changes:
|
0b5429d
to
dde0c4d
Compare
} | ||
config, ok := app.Config.ResolveDomain(domainName) | ||
if ok { | ||
c.CreateDomain(ctx, models.NewDomain( |
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.
Need check error
c.DeleteDomain(ctx, domain.ID, now) | ||
c.CreateDomain(ctx, models.NewDomain( |
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.
Need check error
} | ||
} else { | ||
if domain != nil && domain.AppID == domainVerification.AppID { | ||
c.DeleteDomain(ctx, domain.ID, now) |
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.
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 |
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.
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 { |
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.
No need check nil?
if c.Config.DomainVerificationEnabled { | ||
c.handleDomainVerification(w, r) | ||
} else { | ||
c.handleDomainCreate(w, r) | ||
} | ||
}) |
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.
Can we merge the two functions together?
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) | ||
} |
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.
You can reference RandomID
function instead to use random bytes directly.
@kiootic updated 🙇 |
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.
Thanks!
#7