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

Should the IAuthenticationProviderCallback methods return a Negotiator? #155

Open
PureKrome opened this issue Oct 9, 2014 · 11 comments
Open
Assignees
Labels

Comments

@PureKrome
Copy link
Member

@phillip-haydon bud - now that you've added in a ViewRenderer and Negotiator into the core Nancy with commit dabe211.... , should I be using the Negotiator for the return type instead of a ViewRenderer?

eg.

Negotiator Process(NancyModule nancyModule, AuthenticateCallbackResult result);

The 2x methods in this class can return various things. Generally -> a View to display some html or a Redirect (eg. 301 or 302).

Because it can return a redirect, i'm thinking that i need it to return a Negotiator, right?

@PureKrome PureKrome self-assigned this Oct 9, 2014
@PureKrome PureKrome added this to the 2.0 - .NET 4.5 & Async/Await milestone Oct 9, 2014
@phillip-haydon
Copy link
Member

The problem was that you couldn't access view from INancyModule, so I added view to the interface so your Process can return INancyModule then you can call view from the module directly along with the other extension methods which are implemented against the interface.

@PureKrome
Copy link
Member Author

The problem was that you couldn't access view from INancyModule

yep - that's what I was trying to do and asked for that added.

so I added view to the interface

Yep, so I can now do what I've been trying to do :) sweet!

so your Process can return INancyModule

er.. return an INancyModule ???

this is the bit i'm confused over, now :(

i want to return a response result (ie. a view or a redirect). why would I return an INancyModule... when that is passed in?

@phillip-haydon
Copy link
Member

All the extensions exist on the interface.

Now you can do:

module.Response.AsRedirect(...)

In theory.

Pull the CI build to test with.

@PureKrome
Copy link
Member Author

Yep - i get that .. but why would i want to RETURN the module .. instead of calling the extension inside my Process(..) method and returning an IResponseFormatter or something?

basically - now that you've added in the the two properties to the interface .. what would you recommend is the strong type I should return?

remember - the developer might want to goto

  1. a view (Hi! thanks for signing up).
  2. another existing route (eg. redirect to homepage)
  3. a wizard to ask for more info (eg. email addy cause twitter are f'wits and don't provide it - eg. redirect).

@phillip-haydon
Copy link
Member

You're not returning the module, I don't understand WTF you're asking...

When you return module.View[...] you're returning the view, if you return module.Response.AsRedirect(...) you're returning the type returned by AsRedirect...

@PureKrome
Copy link
Member Author

yep - agreed.

but u said this (which confused me)

so your Process can return INancyModule

which is not returning a view / as redirect.

So - that's been cleared up...

so what is the strong type to return? what is the base type of all of these? I thought I caould return an IReponseFormatter .. but a view isn't that, right?

what about a Negotiator? is that the new fancy way now which I should be returning?

@phillip-haydon
Copy link
Member

Blah, man I never read what I write.

Process(NancyModule nancyModule, ....

I mean it can accept INancyModule as the argument now, rather than the concrete type.

@PureKrome
Copy link
Member Author

HA 😄

so what should it return out of that method, now?

@phillip-haydon
Copy link
Member

dynamic

Unless we're making it async in which case I need to look at Nancy impl.

Nancy uses dynamic to evaluate the type and decide how to handle it, i.e if you return 404 it will handle it as a status code. etc.

@PureKrome
Copy link
Member Author

Urgh.. i was sooooooo afraid you were going to say dynamic because I always try and avoid that :(

I originally had that .. but was trying to avoid it.

But - you're my nancy teacher so I'll change it to dynamic then. Deal?

@phillip-haydon
Copy link
Member

Yes.

PureKrome added a commit to PureKrome/SimpleAuthentication that referenced this issue Oct 10, 2014
- Referencing the NancyFX MyGet library for the latest -pre which includes updates to the INancyModule interface.
- Added a NuGet.config file to reference the MyGet api.
- Removed the ICache (fixes SimpleAuthentication#145).
- Removed the HttpClient code. Now uses the WorldDomination.HttpClient.Helpers package instead.
- Provider key is not required to be sent to the Provider. The session now stores this.
- IAuthenticationProviderCallback returns dynamic (closes SimpleAuthentication#155).
- IAuthenticationProviderCallback methods are not async (closes SimpleAuthentication#151).
@PureKrome PureKrome removed this from the 2.0 - .NET 4.5 & Async/Await milestone Oct 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants