Skip to content
This repository was archived by the owner on Nov 29, 2019. It is now read-only.

Local login#172

Open
maparent wants to merge 22 commits into
developfrom
local_login
Open

Local login#172
maparent wants to merge 22 commits into
developfrom
local_login

Conversation

@maparent

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread assembl/models/auth.py Outdated
assert req
if getattr(req, "lang_prefs", 0) is 0:
# lang. prefs remain effective even without shared login
user_id = req.authenticated_userid

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while you're at it, use authenticated_userid(req)
The syntax req.authenticated_userid is deprecated.

Comment thread assembl/models/preferences.py Outdated
"default": True
},

# Does the Idea panel automatically open when an idea is clicked? (and close when a special section is clicked)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a bad copy-paste? The comment doesn't seem related to this new config.

redirectToJoin() {
const slug = { slug: getDiscussionSlug() };
browserHistory.push(get('join', slug));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to push to customBrowserHistory created in index.jsx
You should export the history variable from index.jsx and use it here.

Comment thread assembl/views/__init__.py Outdated
application_url=application_url,
get_route=get_route,
user=user,
loggedin_userid=request.authenticated_userid,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authenticated_userid(request)

@vincentfretin

Copy link
Copy Markdown
Contributor

Other than that, LGTM.

@vincentfretin

Copy link
Copy Markdown
Contributor

execute npm run format to format with prettier and eslint --fix the js code in v2. This is the same as using the prettier-atom plugin for atom.

@maparent

Copy link
Copy Markdown
Contributor Author

Adjusted to the comments. Good catch about req.authenticated_userid being deprecated.
One thing before we merge: The join page needs to be made prettier. I think someone else will be better positioned to do it.
Also, I think everyone is aware that this only works as such for v2 discussions, and other limits discussed by email. (Adding them to jira while I'm at it.)

@@ -1,9 +1,10 @@
import React from 'react';
import { customBrowserHistory } from '../../index';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

customBrowserHistory is not currently exported in index.jsx. I don't see the change in your PR. You need to add export customBrowserHistory in index.jsx.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right... why didn't webpack complain? (I even tested!)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

webpack will not complain, eslint should have. Try npm run eslint

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, that was helpful, thank you. Have a look now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, should be good.

const connectedUserName = getConnectedUserName();
const alreadyLoggedIn = !!getLoggedInUserId();
const loginOrJoinUrl = alreadyLoggedIn ? get('join', slug) : getContextual('login', slug);
const onClickRedirect = alreadyLoggedIn ? this.redirectToJoin : null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of null, the standard way is to return false

Comment thread assembl/views/__init__.py Outdated
application_url=application_url,
get_route=get_route,
user=user,
loggedin_userid=authenticated_userid(request),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be effectiveuserid here instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loggedin_userid is explicitly about knowing that the person is logged in even though they have no role in the discussion. Adding a comment.



def is_join_route(request):
# TODO: Get a real shared route system for react.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Absolute TODO.



@view_config(route_name='join', request_method='POST')
def do_join_discussion(request):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the ultimate response of this view is to redirect to either a login page or throw an error, we should utilize the new error page that was created for exactly these cases. Instead of returning HTTPUnauthorized or others, should redirect to error page, and pass the error in.

Downstream, that view can respond to the appropriate Error with a client-friendly view (this is not done for all cases, only 404, 401 and 500 I recall)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have an error page now? Then I think that the proper thing to do is to have HTTPUnauthorized go to that error page! Pyramid allows that. Let's discuss it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I discussed it with you a long while back, when logged in users wanted to access a private discussion. Yes, let's discuss when you have a moment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok now that we have a generic error page, this code stands.

@maparent

maparent commented Oct 8, 2017

Copy link
Copy Markdown
Contributor Author

@vincentfretin BTW, I was revisiting authenticated_userid: It's actually the security function that's deprecated, not the request attribute. One of us should revert this.

@vincentfretin

Copy link
Copy Markdown
Contributor

Oh 💩

@vincentfretin

Copy link
Copy Markdown
Contributor

We'll see that when we know what do to with this branch. It's on standby for the moment.

@paolina92

Copy link
Copy Markdown
Contributor

@maparent What do we do with this PR?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants