Giter Club home page Giter Club logo

Comments (6)

icecream78 avatar icecream78 commented on May 24, 2024 1

OK, I''ll try to do it today =)

from auth.

icecream78 avatar icecream78 commented on May 24, 2024

@awalias as far as i understand you want just standardise answers and add to magic link response empty json answer?

from auth.

awalias avatar awalias commented on May 24, 2024

if successful the response should just be {}

if MaxFrequency is broken then we should probably return an error with 429 response code

the problem is we need to suppress the json response from the SignUp method here and here

from auth.

icecream78 avatar icecream78 commented on May 24, 2024

@awalias in cases when SignUp method respond with some error - do we need show same error which reterned from that method?
I have one option for dealing with response from SignUp method. Just implement struct, that fits Response interface and handle response.
For example:
Response stub code

type responseStub struct {
}

func (rw *responseStub) Header() http.Header {
	return nil
}

func (rw *responseStub) Write(data []byte) (int, error) {
	return 0, nil
}

func (rw *responseStub) WriteHeader(statusCode int) {
}

Magic link code

...
if config.Mailer.Autoconfirm {
	// signups are autoconfirmed, send magic link after signup
	if err := a.Signup(fakeResponse, r); err != nil {
		// TODO: handle error
		w.Write(nil)
	}
	newBodyContent := `{"email":"` + params.Email + `"}`
	r.Body = ioutil.NopCloser(strings.NewReader(newBodyContent))
	r.ContentLength = int64(len(newBodyContent))
	return a.MagicLink(fakeResponse, r)
}
// otherwise confirmation email already contains 'magic link'
if err := a.Signup(w, r); err != nil {
	// TODO: handle error
	w.Write(nil)
}

return sendJSON(w, http.StatusOK, make(map[string]string))
....

I'm not sure that this solution is "good". What do you think about that?

from auth.

awalias avatar awalias commented on May 24, 2024

I think it's ok, If you want to make a PR I can test it out today 👍

from auth.

awalias avatar awalias commented on May 24, 2024

nice one @icecream78 !!

from auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.