PLT-44 allow team switching without the need to login
Этот коммит содержится в:
@@ -142,10 +142,10 @@ export default class NavbarDropdown extends React.Component {
|
||||
>
|
||||
</li>
|
||||
);
|
||||
if (this.state.teams.length > 1 && this.state.currentTeam) {
|
||||
var curTeamName = this.state.currentTeam.name;
|
||||
|
||||
if (this.state.teams.length > 1) {
|
||||
this.state.teams.forEach((teamName) => {
|
||||
if (teamName !== curTeamName) {
|
||||
if (teamName !== this.props.teamName) {
|
||||
teams.push(<li key={teamName}><a href={Utils.getWindowLocationOrigin() + '/' + teamName}>{'Switch to ' + teamName}</a></li>);
|
||||
}
|
||||
});
|
||||
@@ -234,5 +234,7 @@ NavbarDropdown.defaultProps = {
|
||||
teamType: ''
|
||||
};
|
||||
NavbarDropdown.propTypes = {
|
||||
teamType: React.PropTypes.string
|
||||
teamType: React.PropTypes.string,
|
||||
teamDisplayName: React.PropTypes.string,
|
||||
teamName: React.PropTypes.string
|
||||
};
|
||||
|
||||
@@ -508,6 +508,7 @@ export default class Sidebar extends React.Component {
|
||||
/>
|
||||
<SidebarHeader
|
||||
teamDisplayName={this.props.teamDisplayName}
|
||||
teamName={this.props.teamName}
|
||||
teamType={this.props.teamType}
|
||||
/>
|
||||
<SearchBox />
|
||||
@@ -587,5 +588,6 @@ Sidebar.defaultProps = {
|
||||
};
|
||||
Sidebar.propTypes = {
|
||||
teamType: React.PropTypes.string,
|
||||
teamDisplayName: React.PropTypes.string
|
||||
teamDisplayName: React.PropTypes.string,
|
||||
teamName: React.PropTypes.string
|
||||
};
|
||||
|
||||
@@ -52,6 +52,8 @@ export default class SidebarHeader extends React.Component {
|
||||
<NavbarDropdown
|
||||
ref='dropdown'
|
||||
teamType={this.props.teamType}
|
||||
teamDisplayName={this.props.teamDisplayName}
|
||||
teamName={this.props.teamName}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -64,5 +66,6 @@ SidebarHeader.defaultProps = {
|
||||
};
|
||||
SidebarHeader.propTypes = {
|
||||
teamDisplayName: React.PropTypes.string,
|
||||
teamName: React.PropTypes.string,
|
||||
teamType: React.PropTypes.string
|
||||
};
|
||||
|
||||
@@ -36,11 +36,14 @@ var RemovedFromChannelModal = require('../components/removed_from_channel_modal.
|
||||
var FileUploadOverlay = require('../components/file_upload_overlay.jsx');
|
||||
var RegisterAppModal = require('../components/register_app_modal.jsx');
|
||||
var ImportThemeModal = require('../components/user_settings/import_theme_modal.jsx');
|
||||
var TeamStore = require('../stores/team_store.jsx');
|
||||
|
||||
var Constants = require('../utils/constants.jsx');
|
||||
var ActionTypes = Constants.ActionTypes;
|
||||
|
||||
function setupChannelPage(props) {
|
||||
TeamStore.setCurrentId(props.TeamId);
|
||||
|
||||
AppDispatcher.handleViewAction({
|
||||
type: ActionTypes.CLICK_CHANNEL,
|
||||
name: props.ChannelName,
|
||||
@@ -71,6 +74,7 @@ function setupChannelPage(props) {
|
||||
React.render(
|
||||
<Sidebar
|
||||
teamDisplayName={props.TeamDisplayName}
|
||||
teamName={props.TeamName}
|
||||
teamType={props.TeamType}
|
||||
/>,
|
||||
document.getElementById('sidebar-left')
|
||||
|
||||
37
web/web.go
37
web/web.go
@@ -189,9 +189,40 @@ func login(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// We still might be able to switch to this team because we've logged in before
|
||||
if multiCookie, err := r.Cookie(model.MULTI_SESSION_TOKEN); err == nil {
|
||||
multiToken := multiCookie.Value
|
||||
|
||||
if len(multiToken) > 0 {
|
||||
tokens := strings.Split(multiToken, " ")
|
||||
|
||||
for _, token := range tokens {
|
||||
if sr := <-api.Srv.Store.Session().Get(token); sr.Err == nil {
|
||||
s := sr.Data.(*model.Session)
|
||||
|
||||
if !s.IsExpired() && s.TeamId == team.Id {
|
||||
w.Header().Set(model.HEADER_TOKEN, s.Token)
|
||||
sessionCookie := &http.Cookie{
|
||||
Name: model.SESSION_TOKEN,
|
||||
Value: s.Token,
|
||||
Path: "/",
|
||||
MaxAge: model.SESSION_TIME_WEB_IN_SECS,
|
||||
HttpOnly: true,
|
||||
}
|
||||
|
||||
http.SetCookie(w, sessionCookie)
|
||||
|
||||
http.Redirect(w, r, c.GetSiteURL()+"/"+team.Name+"/channels/town-square", http.StatusTemporaryRedirect)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
page := NewHtmlTemplatePage("login", "Login")
|
||||
page.Props["TeamDisplayName"] = team.DisplayName
|
||||
page.Props["TeamName"] = teamName
|
||||
page.Props["TeamName"] = team.Name
|
||||
page.Render(c, w)
|
||||
}
|
||||
|
||||
@@ -319,7 +350,7 @@ func getChannel(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
// lets make sure the user is valid
|
||||
if result := <-api.Srv.Store.User().Get(c.Session.UserId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
c.RemoveSessionCookie(w)
|
||||
c.RemoveSessionCookie(w, r)
|
||||
l4g.Error("Error in getting users profile for id=%v forcing logout", c.Session.UserId)
|
||||
return
|
||||
}
|
||||
@@ -344,6 +375,7 @@ func getChannel(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
page := NewHtmlTemplatePage("channel", "")
|
||||
page.Props["Title"] = name + " - " + team.DisplayName + " " + page.ClientProps["SiteName"]
|
||||
page.Props["TeamDisplayName"] = team.DisplayName
|
||||
page.Props["TeamName"] = team.Name
|
||||
page.Props["TeamType"] = team.Type
|
||||
page.Props["TeamId"] = team.Id
|
||||
page.Props["ChannelName"] = name
|
||||
@@ -451,6 +483,7 @@ func resetPassword(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
page := NewHtmlTemplatePage("password_reset", "")
|
||||
page.Props["Title"] = "Reset Password " + page.ClientProps["SiteName"]
|
||||
page.Props["TeamDisplayName"] = teamDisplayName
|
||||
page.Props["TeamName"] = teamName
|
||||
page.Props["Hash"] = hash
|
||||
page.Props["Data"] = data
|
||||
page.Props["TeamName"] = teamName
|
||||
|
||||
Ссылка в новой задаче
Block a user