@@ -67,91 +67,6 @@ |
version=get_version(), meta=meta)) |
return [dict(url) for url in api_urls] |
|
- |
-def er2_login_disable_oauth(default): |
- return True |
- |
- |
-def er2_login_enable_direct_sign_in(default): |
- return True |
- |
- |
-def er2_login_get_page_name(default=None): |
- return "Edge of Field Database" |
- |
- |
-def er2_login_scratch_project_url(default): |
- return { |
- "name": "New Project", |
- "url": "/?token=_new", |
- } |
- |
- |
-def hash_password(password): |
- """Hash a password for storing.""" |
- salt = hashlib.sha256(os.urandom(60)).hexdigest().encode("ascii") |
- pwdhash = hashlib.pbkdf2_hmac( |
- "sha512", password.encode("utf-8"), salt, 100000) |
- pwdhash = binascii.hexlify(pwdhash) |
- return (salt + pwdhash).decode("ascii") |
- |
- |
-def verify_password(stored_password, provided_password): |
- """Verify a stored password against one provided by user""" |
- import hashlib |
- import binascii |
- |
- salt = stored_password[:64] |
- stored_password = stored_password[64:] |
- pwdhash = hashlib.pbkdf2_hmac( |
- "sha512", provided_password.encode( |
- "utf-8"), salt.encode("ascii"), 100000 |
- ) |
- pwdhash = binascii.hexlify(pwdhash).decode("ascii") |
- return pwdhash == stored_password |
- |
- |
-# TODO: I would think this could be moved directly into er2_login/services.py |
-def er2_login_handle_authentication(request, user_attrs): |
- user_id, email, first_name, last_name, attrs = [None] * 5 |
- if "username" in user_attrs: |
- users_path = "/gis_data/users/users_eofdb_hashed.json" |
- with open(users_path) as fp: |
- users = json.load(fp)["users"] |
- user_info = users.get(user_attrs["username"], None) |
- if user_info: |
- pw_hashed = user_info["password"] |
- if verify_password(pw_hashed, user_attrs["password"]): |
- user_id = user_attrs["username"] |
- attrs = { |
- "projects": [ |
- { |
- "name": user_id, |
- "type": "eofDB", |
- "url": "/?token={0}".format(user_info["project"]), |
- }, |
- ], |
- } |
- request.session["token"] = user_info["project"] |
- else: |
- raise LoginException("Login failed") |
- else: |
- raise LoginException("User does not exist") |
- else: |
- # anonymous login |
- attrs = { |
- "projects": [ |
- { |
- "name": "guest", |
- "type": "eofdb", |
- "url": "/?token={0}".format(er2_strings.rand()), |
- }, |
- ], |
- } |
- |
- return user_id, email, first_name, last_name, attrs |
- |
- |
logger = logging.getLogger('er2') |
|
class State(er2_state.State): |
@@ -114,6 +114,7 @@ |
onUpdateMapView: Function, |
onUploadLocal: Function, |
setAdvancedSetting: Function, |
+ setDefaultBaseLayer: Function, |
setFeatureBorderWidth: Function, |
setFeatureColor: Function, |
setFeatureOpacity: Function, |
@@ -241,7 +242,6 @@ |
const { keycloak, setCurrentToken, userState } = catenaKeycloak |
const users = useSelector(state => state.users) |
|
- |
const catenaMap = React.useRef(null) |
const { location } = window |
const parsedLoc = parseLocation(window.location) |
@@ -260,13 +260,14 @@ |
const dispatch = useDispatch() |
const { token, actions } = theprops |
const { fetchState } = actions |
+ const [userRoleConservationist, setUserRoleConservationist] = React.useState(false) |
|
- const [userRoleConservationist, setUserRoleConservationist] = React.useState(false) |
+ console.log({token: token.value}) |
|
useEffect(() => { |
if (keycloak.authenticated && userState) { |
const currentToken = userState.currentToken |
- |
+ |
// First check for initial load of project (token will be null) |
if (!token.value) { |
if (currentToken) { |
@@ -302,7 +303,6 @@ |
|
|
useEffect(() => { |
- console.log(users) |
if (users.user.id) { |
setUserRoleConservationist('Conservationist' === users.user['role']) |
} |
@@ -332,13 +332,9 @@ |
|
useEffect(() => { |
theprops.actions.getUsersFromDB() |
+ theprops.actions.setDefaultBaseLayer('USGS Imagery Topo') |
}, []) |
|
- |
- const logout = () => { |
- keycloak.logout() |
- } |
- |
function renderHeader() { |
let loginSection |
|