# How would you go about this?

**URL:** <https://forum.freecodecamp.org/t/how-would-you-go-about-this/450369>\
**Category:** General\
**Created:** [March 9, 2021, 11:15pm UTC](https://forum.freecodecamp.org/t/how-would-you-go-about-this/450369 "2021-03-09T23:15:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wbrown152020](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/wbrown152020/32/206429_2.png) [@wbrown152020](https://forum.freecodecamp.org/u/wbrown152020)\
**Post date:** [March 9, 2021, 11:15pm UTC](https://forum.freecodecamp.org/t/how-would-you-go-about-this/450369/1 "2021-03-09T23:15:13Z")

</div>

I am doing a project with authentication with passport js with the Strategies (Google, Facebook, Local). I am working on the google part now but there is a small problem. When users register locally I save their data to the db (email,username,hashedPassword) but now when they register/signin through google I do not have access to their password (obviously). It is required in the user schema and I do not want to create a new user schema.

Could I save the password as the user id I received from google?

---

<div class="post-metadata">

**Author:** ![bradtaniguchi](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bradtaniguchi/32/110427_2.png) [@bradtaniguchi](https://forum.freecodecamp.org/u/bradtaniguchi)\
**Post date:** [March 9, 2021, 11:51pm UTC](https://forum.freecodecamp.org/t/how-would-you-go-about-this/450369/2 "2021-03-09T23:51:59Z")

</div>

Since your application only needs/saves a password for a user if they login via local-auth (username+password) you could update your schema to make this field optional based upon which method they used to login.

**Or** handle it at another level, rather than the schema itself and make the field optional.

**Or** have multiple schemas for the different login methods that are then “inherited” depending on different attributes on the user-account. Like have a `authType` and setup multiple schemas that are used depending on which `authType` the user is logging in with

**Or** don’t use local auth at all and never deal with passwords (yay)

**Or** use a mix of any of these approaches.

* * *

I personally would throw out the local-auth because I don’t like to deal with passwords on any of my apps. If that isn’t an option and you must support multiple authentication methods internally, you have a number of options, most of which focus on making the password property not be required conditionally.

---

<div class="post-metadata">

**Author:** ![wbrown152020](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/wbrown152020/32/206429_2.png) [@wbrown152020](https://forum.freecodecamp.org/u/wbrown152020)\
**Post date:** [March 10, 2021, 9:51pm UTC](https://forum.freecodecamp.org/t/how-would-you-go-about-this/450369/3 "2021-03-10T21:51:37Z")

</div>

I added a provider to the schema. So if the provider is not local, then the password is not required

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [September 9, 2021, 9:51am UTC](https://forum.freecodecamp.org/t/how-would-you-go-about-this/450369/4 "2021-09-09T09:51:42Z")

</div>

Closed on September 9, 2021, 9:51am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
