Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
How do I pass another argument to onSelectChange?

code:
class App extends React.Component{

  onSelectChange(e){
     console.log(e.target.value);
  }

  render(){
     return(
       <select onChange={this.onSelectChange}>
         <option value='1'>1</option>
         <option value='2'>2</option>
         <option value='3'>3</option>
       </select>
     )  
  }
}

ReactDOM.render(<App/>, document.getElementById('app'))

Adbot
ADBOT LOVES YOU

reversefungi
Nov 27, 2003

Master of the high hat!

Grump posted:

How do I pass another argument to onSelectChange?


Just do this:

code:
class App extends React.Component{
  ... etc

  render(){
     return(
       <select onChange={e => this.onSelectChange(e, otherArg)}>
         <option value='1'>1</option>
         <option value='2'>2</option>
         <option value='3'>3</option>
       </select>
     )  
  }
}

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

Thermopyle posted:

Also, redux is awesome.

Mutable state is awesome. I cannot willingly go back ever. `mobx` is the new kid on the block redux alt.

Nolgthorn fucked around with this message at 23:25 on Sep 23, 2017

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Nolgthorn posted:

Mutable state is awesome.

What? no one says this.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself

The Dark Wind posted:

Just do this:

code:

class App extends React.Component{
  ... etc

  render(){
     return(
       <select onChange={e => this.onSelectChange(e, otherArg)}>
         <option value='1'>1</option>
         <option value='2'>2</option>
         <option value='3'>3</option>
       </select>
     )  
  }
}


Thanks. For some reason, my brain always thinks writing functions inline is bad

Odette
Mar 19, 2011

Nolgthorn posted:

Mutable state is awesome. I cannot willingly go back ever. `mobx` is the new kid on the block redux alt.

What the gently caress are you smoking?

Ruggan
Feb 20, 2007
WHAT THAT SMELL LIKE?!


I'm doing some internal web dev at my salaried job. Most of my self-taught experience has been doing MVC ASP.NET dev, SQL backend with Dapper DAL. Front end is just a bunch of views and jquery with Ajax calls returning data / partial views. I kinda want to explore doing some better front end UI stuff - is react still the hotness, or is vue the new flavor of the month? Is there any relevance to the backlash around the new react license?

geeves
Sep 16, 2004

Ruggan posted:

I'm doing some internal web dev at my salaried job. Most of my self-taught experience has been doing MVC ASP.NET dev, SQL backend with Dapper DAL. Front end is just a bunch of views and jquery with Ajax calls returning data / partial views. I kinda want to explore doing some better front end UI stuff - is react still the hotness, or is vue the new flavor of the month? Is there any relevance to the backlash around the new react license?

Getting into a car with any JS framework is like getting into the convertible with Raoul Duke and Dr. Gonzo high on drugs, "We're your friends, we're not like the others."

Redmark
Dec 11, 2012

This one's for you, Morph.
-Evo 2013

Ruggan posted:

I'm doing some internal web dev at my salaried job. Most of my self-taught experience has been doing MVC ASP.NET dev, SQL backend with Dapper DAL. Front end is just a bunch of views and jquery with Ajax calls returning data / partial views. I kinda want to explore doing some better front end UI stuff - is react still the hotness, or is vue the new flavor of the month? Is there any relevance to the backlash around the new react license?

Disclaimer: work at Facebook

I think legally speaking BSD + PATENTS wasn't that bad, and in fact moving to MIT just makes the patent situation more ambiguous (not a lawyer but the conventional wisdom is that it gives an implicit grant, not tested in court, use at your own risk, blah blah blah). But it's a license that's used ubiquitously and is associated with open source projects. No one ever got fired for going with MIT, basically, while plenty of legal departments were balking at a Facebook-unique license (Wordpress and Baidu being the major ones I know of).

Basically the old PATENTS has been there for years and no one's gotten sued over a hypothetical React patent yet. If such a suit did happen you can be sure it would be a massive shitstorm, so I'm fairly confident it won't. AFAIK the situation is now equivalent to all the other libraries backed by big companies that use MIT.

Also React is cool and good for what it's worth. A lot is made of framework churn in JS-land, but all the major competitors are backed by big users and likely to stick around for a long time, so it's really up to the individual to avoid decision paralysis. Don't be afraid to just pick one that feels the smoothest for you.

reversefungi
Nov 27, 2003

Master of the high hat!

Ruggan posted:

I'm doing some internal web dev at my salaried job. Most of my self-taught experience has been doing MVC ASP.NET dev, SQL backend with Dapper DAL. Front end is just a bunch of views and jquery with Ajax calls returning data / partial views. I kinda want to explore doing some better front end UI stuff - is react still the hotness, or is vue the new flavor of the month? Is there any relevance to the backlash around the new react license?

I learned React during my bootcamp and found it pretty intuitive thanks to JSX and simple to pickup, but apparently a lot of people feel that it has a big learning curve, especially with Redux, so YMMV. I've been trying to teach myself Vue.js before I start my new job next month since it's used on some projects, and so far I have to say it's a really nice and straightforward framework. The documentation is fantastic. Things do exactly what you expect them to do. I don't think you can go wrong with trying either.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

Odette posted:

What the gently caress are you smoking?

I'm smoking vuex since quitting redux, I still use some redux from time to time for work but I'm quitting that too.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

Grump posted:

Thanks. For some reason, my brain always thinks writing functions inline is bad

In this case it shouldn't matter. But you could:

code:
class App extends React.Component{
  constructor() {
    super();
    this._onChange = this._onChange.bind(this);
  }

  _onChange (e) {
    this.onSelectChange(e, otherArg);
  }

  ... etc

  render(){
     return(
       <select onChange={this._onChange}>
         <option value='1'>1</option>
         <option value='2'>2</option>
         <option value='3'>3</option>
       </select>
     )  
  }
}
You should do that for `ref=` because react doesn't handle it very well, it would have to unassign the reference and then assign it again on every rerender, because the function changes.

SimonChris
Apr 24, 2008

The Baron's daughter is missing, and you are the man to find her. No problem. With your inexhaustible arsenal of hard-boiled similes, there is nothing you can't handle.
Grimey Drawer
code:
<select onChange={this.onSelectChange.bind(this, otherArg)}>
You can also use "bind".

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Bind returns a new reference, it performs essentially the same thing as an inline function in this case.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Nolgthorn posted:

Bind returns a new reference, it performs essentially the same thing as an inline function in this case.

well, it's more that bind makes it so when the event handler is called, the context of the invoked function is the object passed in as first parameter, with the parameters being the subsequent args. arrow function and bound functions are pretty similar, but I generally like bound functions over arrow functions in event handlers because arrow functions can't be invoked recursively (as they are not named functions) and you might want to invoke an event handler recursively so you can debounce it.

The Merkinman
Apr 22, 2007

I sell only quality merkins. What is a merkin you ask? Why, it's a wig for your genitals!
Every time I read this thread, I feel dumb for officially/unofficially deciding on Angular where I work. :sigh:

TheCog
Jul 30, 2012

I AM ZEPA AND I CLAIM THESE LANDS BY RIGHT OF CONQUEST

The Merkinman posted:

Every time I read this thread, I feel dumb for officially/unofficially deciding on Angular where I work. :sigh:

Angular is cool and good.

TheCog fucked around with this message at 16:57 on Sep 24, 2017

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

The Merkinman posted:

Every time I read this thread, I feel dumb for officially/unofficially deciding on Angular where I work. :sigh:

There's nothing wrong with Angular really...its right in there with React and Vue as far as being a modern thing that makes front end work better.

Personally, I wouldn't pick it but that's not because it's a stupid and dumb thing to use. I just don't like the way it works compared to React or Vue...but that's relative. On a scale of 1 to 100 with 100 being what I most prefer and think is least dumb, from my standpoint React is like 100, Vue is 99, Angular is 90, and then you're down in the 60s-70s with stuff like Ember and going on down.

Those rankings kind of combine stuff like using what I'm familiar with, preferences about how you work with them, community support, etc. React I've used a lot, Vue I've just dabbled with, Angular is somewhere in between those two, and I haven't touched any of the other stuff in years other than just keeping up with the frontend framework blogosphere.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Thermopyle posted:

There's nothing wrong with Angular really...its right in there with React and Vue as far as being a modern thing that makes front end work better.

Angular early adopters were smoking crack. Recent angular is better but it still has a learning curve. I'd be willing to work with a project that uses a recent angular but I probably wouldn't pick it for a new project.

Love Stole the Day
Nov 4, 2012
Please give me free quality professional advice so I can be a baby about it and insult you
You know what'd be useful? If there were a series of "____ for people who already know ____" guides. (e.g. "Angular for people who already know React")

huhu
Feb 24, 2006

Love Stole the Day posted:

You know what'd be useful? If there were a series of "____ for people who already know ____" guides. (e.g. "Angular for people who already know React")

If a framework specific tutorial becomes useless at a speed of N, these surely would become useless at a speed of N^2.

geeves
Sep 16, 2004

huhu posted:

If a framework specific tutorial becomes useless at a speed of N, these surely would become useless at a speed of N^2.

And if you know when it is N log N you'll do fine on your next interview.

dupersaurus
Aug 1, 2012

Futurism was an art movement where dudes were all 'CARS ARE COOL AND THE PAST IS FOR CHUMPS. LET'S DRAW SOME CARS.'
You could probably do a guide like that pretty well as long as you talk about the right stuff. The difficultly of jumping between stuff like angular and react isn't apis and plugins, but the different philosophies of how things go together. And that sort of thing doesn't change as frequently.

HaB
Jan 5, 2001

What are the odds?

Thermopyle posted:

There's nothing wrong with Angular really...its right in there with React and Vue as far as being a modern thing that makes front end work better.

Personally, I wouldn't pick it but that's not because it's a stupid and dumb thing to use. I just don't like the way it works compared to React or Vue...but that's relative. On a scale of 1 to 100 with 100 being what I most prefer and think is least dumb, from my standpoint React is like 100, Vue is 99, Angular is 90, and then you're down in the 60s-70s with stuff like Ember and going on down.

Those rankings kind of combine stuff like using what I'm familiar with, preferences about how you work with them, community support, etc. React I've used a lot, Vue I've just dabbled with, Angular is somewhere in between those two, and I haven't touched any of the other stuff in years other than just keeping up with the frontend framework blogosphere.

This. But from the other side.

I really like Angular, but that's what I'm most familiar with by FAR. Every time I try to do something in React, I give up and do it in Angular. Is it any easier in Angular? For me it is. But again - that's only because Angular has been my moneymaker for the past 5 years and React I have only dabbled in.

I'm sure to a developer who has never worked with either one, they both have equal levels of tedium/nonsense.

I will say this - and I know it holds true for Angular, and seems like it does for React/Redux, tho one of the more experienced React devs can confirm:

EMBRACE whatever framework you choose. FULLY. Open up them lovin' arms and give it a big old hug. I say this because the only people I have seen struggle with either framework are the ones who are like "well I'm just gonna do this little thing in JQuery/Underscore/whatever because that's what I know." I'm here to tell you: that way lies madness. Both React and Angular are pretty opinionated about how you do things. But I can't think of a single instance when it simply wasn't possible to find a framework-specific way to do X, no matter what X is. So if you're going in - go ALL in. Trust me. Even tiny little things like: "I'm just gonna use jQuery to add a class to this button. It'll be fine." Nope. Don't do it.

You shouldn't ever have to fight against the framework you are using - but understand there is a vast difference between "fighting" and "refusing to learn/sticking with what you already know because reasons".

I will leave it to Thermopyle to chime in re: React.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
That kinda makes me curious. Has anyone ever HAD to switch because of a new job and ended up changing their opinion on whatever framework?

I'm not going out of my way to find angular jobs, but I'm not really sure how easily I'd adjust if my job went from React to Angular.

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS
The technology you use is irrelevant. A framework or language or whatever is a tool, not a way of life.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

HaB posted:

I will leave it to Thermopyle to chime in re: React.

Ditto. Once or twice I've went through a lot of work of making a jQuery plugin work but that was a lot of pain and I had determined that reimplementing it in React would be even more pain.


Grump posted:

That kinda makes me curious. Has anyone ever HAD to switch because of a new job and ended up changing their opinion on whatever framework?

I'm not going out of my way to find angular jobs, but I'm not really sure how easily I'd adjust if my job went from React to Angular.

This would be a weird thing to do. Just learn the framework.


Well, that was my first reaction, but then I started thinking...if my job switched to PHP (yeah, not a framework, but whatever), I'd start looking for a new job, so there's some level of friction that I'm not willing to put up with.

On the frontend I'd use Angular or Vue or React or whatever other modern framework I'm not thinking of, but I'd really start thinking about looking for a new job if I had to use something from 5 or 10 years ago.

luchadornado
Oct 7, 2004

A boombox is not a toy!

Angular is an opinionated framework in a sea of unopinionated libraries that you're expected to cobble together yourself and impose your own opinion. Some of the front-end developers I've worked with are bad at forming and imposing opinions.

Redux is an incomplete concept crucially missing functional staples of better languages, and is touted as the go-to way to manage state in React, which is probably frustrating to a lot of people.

Immutable state isn't the panacea it's made out to be. Apps built with Immutable.js and Redux have plenty of errors - I've seen many stemming from trying to embrace immutability, overusing thunks, and creating complex middleware.

Blinkz0rz posted:

The technology you use is irrelevant. A framework or language or whatever is a tool, not a way of life.

Quoted for truth. I switched from .NET MVC -> React/Redux -> Groovy/Ratpack. Many, many of the concepts are the same, it's just a matter of learning where the new buttons on your tools are. No tool is perfect.

Thermopyle posted:

I'd really start thinking about looking for a new job if I had to use something from 5 or 10 years ago.
This is a good point if you care about progressing in your career. Not paying down tech debt can be a symptom of bigger problems in the organization. If you're organization isn't looking at .NET Core, Java 9/Kotlin, React/Angular 2/Vue or whatever that's recent from the last few years, you might want to figure out why. Lack of funding/strategy from the executive level, peers that are complacent, etc. If you're someone that wants to keep getting better, why would you want to be in such an environment?

luchadornado fucked around with this message at 17:50 on Sep 25, 2017

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Helicity posted:

Angular is an opinionated framework in a sea of unopinionated libraries that you're expected to cobble together yourself and impose your own opinion. Some of the front-end developers I've worked with are bad at forming and imposing opinions.

Truth.

Helicity posted:

Redux is an incomplete concept crucially missing functional staples of better languages, and is touted as the go-to way to manage state in React, which is probably frustrating to a lot of people.

Redux is incomplete in the sense that React is incomplete.

Helicity posted:

Immutable state isn't the panacea it's made out to be. Apps built with Immutable.js and Redux have plenty of errors - I've seen many stemming from trying to embrace immutability, overusing thunks, and creating complex middleware.

I'm not sure that immutableness is made out to be a panacea by anyone worth listening to (I guess thats a no true scotsman fallacy, but then again I'm not sure how exactly to respond to the comment about it not being the panacea it's made out to be). Immutable state does not eliminate bugs, just like static typing does not eliminate bugs.

You can use all technologies incorrectly. Immutable state is just another tool like static typing that has to be used in the correct way to realize its benefits.

It's not like you can slap an immutable state library into your application and go "woop bugs fixed".

luchadornado
Oct 7, 2004

A boombox is not a toy!

Thermopyle posted:

Redux is incomplete in the sense that React is incomplete.


I'm not sure that immutableness is made out to be a panacea by anyone worth listening to (I guess thats a no true scotsman fallacy, but then again I'm not sure how exactly to respond to the comment about it not being the panacea it's made out to be). Immutable state does not eliminate bugs, just like static typing does not eliminate bugs.

I'm not disagreeing, but I wanted to clarify. This is just my experience in the Minneapolis software community.

Most of us will at least agree that mutable state can cause weird, hard to triage bugs. But you can program more defensively and do some triage and move on. I've seen a lot of great code that mutates things - from a performance aspect, sometimes you want to mutate the original because clones are expensive!

I've met a subset of people, and I'd probably put their numbers in the dozens, who think immutability solves way more problems. Nearly all of them are front-end developers that have drunk the Kool-Aid. They don't consider the ROI they get, and they will go to great lengths to preserve immutability in their applications, even to the detriment of other things. It feels cargo cultish. I'd put immutability towards the bottom of the pile of things I consider helpful in preventing bugs *across the board*. In certain use cases, when I see that state will be problematic, I'll make more efforts to address it.

My beef with Redux is that there was poor documentation for years, it still encourages a ton of boilerplate, what I consider a harmful misdirection to thunks instead of middleware, and the language doesn't really support the things it needs to be simple and intuitive. Javascript with baked in immutable data structures would be much, much better. If someone came out with a version of Redux with baked in immutability and a reduction in boilerplate, I think it would be huge.

Ruggan
Feb 20, 2007
WHAT THAT SMELL LIKE?!


Maybe someone can bring me some clarity here. I'm looking to try out using ReactJS in some internal projects. The current stack is SQL Server --> ASP.NET application --> HTML/JS/jQuery. I develop in Visual Studio. We host through IIS.

Let's say I want to start using React. Should I be planning to turn my existing ASP.NET app into a web API? Instead of serving pages, just serve data and consume that via Fetch ajax requests into React/Redux and render my page based on state?

What is the code editor(s) of choice for React / JS driven front-ends? Visual Studio's tooling seems to be a little lacking.

The Fool
Oct 16, 2003


Ruggan posted:

Maybe someone can bring me some clarity here. I'm looking to try out using ReactJS in some internal projects. The current stack is SQL Server --> ASP.NET application --> HTML/JS/jQuery. I develop in Visual Studio. We host through IIS.

Let's say I want to start using React. Should I be planning to turn my existing ASP.NET app into a web API? Instead of serving pages, just serve data and consume that via Fetch ajax requests into React/Redux and render my page based on state?

What is the code editor(s) of choice for React / JS driven front-ends? Visual Studio's tooling seems to be a little lacking.

Most people I know consider that to be the best practice.

Check out VSCode for the html/js stuff.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Ruggan posted:

Maybe someone can bring me some clarity here. I'm looking to try out using ReactJS in some internal projects. The current stack is SQL Server --> ASP.NET application --> HTML/JS/jQuery. I develop in Visual Studio. We host through IIS.

Let's say I want to start using React. Should I be planning to turn my existing ASP.NET app into a web API? Instead of serving pages, just serve data and consume that via Fetch ajax requests into React/Redux and render my page based on state?

What is the code editor(s) of choice for React / JS driven front-ends? Visual Studio's tooling seems to be a little lacking.

That is probably the ideal way, but there's certainly nothing wrong with starting smaller.

Take a form or a widget of some sort and re-implement it in React. React doesn't really care where its data comes from, you just have to make it accessible to it. That can be as simple as dropping a big global JS object into your templates with the data it needs.

I prefer Webstorm for frontend web dev.

The Fool
Oct 16, 2003


Thermopyle posted:

That can be as simple as dropping a big global JS object into your templates with the data it needs.


Amusing anecdote, before I had learned about redux, this is how I stored state in a couple personal projects.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I had a mouseover event instead of mouseenter and I didn't notice because in Vuex it had 0 performance overhead.

Having access to `this.$store` `this.$getters` `this.$route` `this.$socket` etc etc all the time is great. When I wanna update something in the store I just change it. I don't need `mapStateToProps` or `mapDispatchToProps`. The only "problem" per say is that you cannot do key assignment.

code:
this.$store.state.messages[myKey] = myMessage;
Needs to be.

code:
Vue.set(this.$store.state.messages, myKey, myMessage);
Otherwise Vuex has no way of knowing the object changed apparently. Similar with delete. So that could cause an issue for the not careful. Still, I don't think I'd give up mutable state now that I've tried this stuff it's too easy and too performant.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Nolgthorn posted:

I had a mouseover event instead of mouseenter and I didn't notice because in Vuex it had 0 performance overhead.

Having access to `this.$store` `this.$getters` `this.$route` `this.$socket` etc etc all the time is great. When I wanna update something in the store I just change it. I don't need `mapStateToProps` or `mapDispatchToProps`. The only "problem" per say is that you cannot do key assignment.

code:
this.$store.state.messages[myKey] = myMessage;
Needs to be.

code:
Vue.set(this.$store.state.messages, myKey, myMessage);
Otherwise Vuex has no way of knowing the object changed apparently. Similar with delete. So that could cause an issue for the not careful. Still, I don't think I'd give up mutable state now that I've tried this stuff it's too easy and too performant.

Yes, mutable state is easier when your project is small. Heck, its even easier when your project is bigger.

Much like not having static types is easier.

Ruggan
Feb 20, 2007
WHAT THAT SMELL LIKE?!


Erm ok. If the web API is hosted on IIS and depends on windows authentication, how do I pass that from my react app to IIS?

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
You gotta set the header manually.

https://coderseye.com/2007/how-to-do-http-basic-auth-in-ajax.html

* get base64.js

code:
function make_base_auth(user, password) {
  var tok = user + ':' + pass;
  var hash = Base64.encode(tok);
  return "Basic " + hash;
}

const auth = make_basic_auth('me', 'mypassword');
const url = 'http://example.com';

xml = new XMLHttpRequest();
xml.setRequestHeader('Authorization', auth);
xml.open('GET', url);

Ruggan
Feb 20, 2007
WHAT THAT SMELL LIKE?!


Nolgthorn posted:

You gotta set the header manually.

https://coderseye.com/2007/how-to-do-http-basic-auth-in-ajax.html

* get base64.js

code:
function make_base_auth(user, password) {
  var tok = user + ':' + pass;
  var hash = Base64.encode(tok);
  return "Basic " + hash;
}

const auth = make_basic_auth('me', 'mypassword');
const url = 'http://example.com';

xml = new XMLHttpRequest();
xml.setRequestHeader('Authorization', auth);
xml.open('GET', url);

Yeah, that makes sense, except I'm not sure where to get the user and password, unless I'm expected to ask the user which I don't want to do.

In the .NET world, I can detect the browsing user's windows login in a controller and use that to control security. For instance, at my company, I can get data on that user based on windows login and determine if they're a manager, then use that to grant or deny access to certain things. This all happens under the hood with Active Directory and to the end user it's seamless.

If I'm abstracting this away into a Web API, I need some way to pass that info to the API from my app (via fetch I presume) and I want to be able to do this automatically - no login screen or anything. So it needs to be passthrough authentication or something like that. Is there a fetch setting that will pass windows auth through to a web API?

Adbot
ADBOT LOVES YOU

Sedro
Dec 31, 2008

Ruggan posted:

Yeah, that makes sense, except I'm not sure where to get the user and password, unless I'm expected to ask the user which I don't want to do.

In the .NET world, I can detect the browsing user's windows login in a controller and use that to control security. For instance, at my company, I can get data on that user based on windows login and determine if they're a manager, then use that to grant or deny access to certain things. This all happens under the hood with Active Directory and to the end user it's seamless.

If I'm abstracting this away into a Web API, I need some way to pass that info to the API from my app (via fetch I presume) and I want to be able to do this automatically - no login screen or anything. So it needs to be passthrough authentication or something like that. Is there a fetch setting that will pass windows auth through to a web API?

If your backend API supports Windows auth, the browser will take care of it without any extra code on the frontend

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply