Adding device Id for version 2 of native apps (#5505)
* Adding device Id for version 2 * Changing ids
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
3b0f7163ab
Коммит
ca7d3b6e7b
@@ -206,11 +206,6 @@ func attachDeviceId(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if !(strings.HasPrefix(deviceId, model.PUSH_NOTIFY_APPLE+":") || strings.HasPrefix(deviceId, model.PUSH_NOTIFY_ANDROID+":")) {
|
||||
c.SetInvalidParam("attachDevice", "deviceId")
|
||||
return
|
||||
}
|
||||
|
||||
// A special case where we logout of all other sessions with the same device id
|
||||
if err := app.RevokeSessionsForDeviceId(c.Session.UserId, deviceId, c.Session.Id); err != nil {
|
||||
c.Err = err
|
||||
|
||||
@@ -1114,6 +1114,37 @@ func TestUserUpdateDeviceId(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUserUpdateDeviceId2(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team)
|
||||
|
||||
user := &model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, team)
|
||||
store.Must(app.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.Login(user.Email, "passwd1")
|
||||
Client.SetTeamId(team.Id)
|
||||
deviceId := model.PUSH_NOTIFY_APPLE_REACT_NATIVE + ":1234567890"
|
||||
|
||||
if _, err := Client.AttachDeviceId(deviceId); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if result := <-app.Srv.Store.Session().GetSessions(user.Id); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
} else {
|
||||
sessions := result.Data.([]*model.Session)
|
||||
|
||||
if sessions[0].DeviceId != deviceId {
|
||||
t.Fatal("Missing device Id")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUserUpdateActive(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
Client := th.BasicClient
|
||||
|
||||
Ссылка в новой задаче
Block a user