fix Staff class,canManageTicket function to camelcase form.fix bug edit commment FE id ternary
This commit is contained in:
parent
4b2d27e757
commit
d0a6dd06d8
|
@ -58,7 +58,7 @@ export default {
|
|||
}
|
||||
}).then((result) => {
|
||||
store.dispatch(this.getUserData(result.data.userId, result.data.token));
|
||||
|
||||
|
||||
return result;
|
||||
})
|
||||
};
|
||||
|
|
|
@ -117,7 +117,7 @@ class TicketEvent extends React.Component {
|
|||
return (
|
||||
<div className="ticket-event__comment-content">
|
||||
<div dangerouslySetInnerHTML={{__html: this.props.content}}></div>
|
||||
{((this.props.author.id === this.props.userId) || (this.props.userStaff)) ? this.renderEditIcon() : null}
|
||||
{((this.props.author.id == this.props.userId && this.props.author.staff == this.props.userStaff) || this.props.userStaff) ? this.renderEditIcon() : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -69,7 +69,6 @@ class TicketViewer extends React.Component {
|
|||
|
||||
render() {
|
||||
const ticket = this.props.ticket;
|
||||
|
||||
return (
|
||||
<div className="ticket-viewer">
|
||||
<div className="ticket-viewer__header row">
|
||||
|
@ -605,6 +604,7 @@ class TicketViewer extends React.Component {
|
|||
}
|
||||
|
||||
export default connect((store) => {
|
||||
|
||||
return {
|
||||
userId: store.session.userId,
|
||||
userStaff: store.session.staff,
|
||||
|
|
|
@ -77,7 +77,8 @@ class SessionReducer extends Reducer {
|
|||
logged: true,
|
||||
pending: false,
|
||||
failed: false,
|
||||
userId: payload.data.userId
|
||||
userId: payload.data.userId,
|
||||
staff: payload.data.staff
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -94,6 +95,7 @@ class SessionReducer extends Reducer {
|
|||
sessionStore.storeRememberData({
|
||||
token: resultData.rememberToken,
|
||||
userId: resultData.userId,
|
||||
staff: resultData.staff,
|
||||
expiration: resultData.rememberExpiration
|
||||
});
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ class GetUserController extends Controller {
|
|||
Response::respondSuccess([
|
||||
'name' => $user->name,
|
||||
'email' => $user->email,
|
||||
'staff' => false,
|
||||
'verified' => !$user->verificationToken,
|
||||
'tickets' => $parsedTicketList,
|
||||
'customfields' => $user->xownCustomfieldvalueList->toArray(),
|
||||
|
|
|
@ -108,7 +108,7 @@ class LoginController extends Controller {
|
|||
return array(
|
||||
'userId' => $userInstance->id,
|
||||
'userEmail' => $userInstance->email,
|
||||
'staff' => Controller::request('staff'),
|
||||
'staff' => !!Controller::request('staff'),
|
||||
'token' => Session::getInstance()->getToken(),
|
||||
'rememberToken' => $this->rememberToken,
|
||||
'rememberExpiration' => $this->rememberExpiration
|
||||
|
|
|
@ -50,7 +50,7 @@ class Staff extends DataStore {
|
|||
}
|
||||
|
||||
public function canManageTicket(Ticket $ticket){
|
||||
return $this->sharedDepartmentList->includesId($ticket->departmentId) || $this->id === $ticket->author_staff_id;
|
||||
return $this->sharedDepartmentList->includesId($ticket->departmentId) || $this->id === $ticket->authorStaffId;
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
|
|
|
@ -21,6 +21,20 @@ describe '/ticket/seen' do
|
|||
end
|
||||
|
||||
describe 'when an user is logged' do
|
||||
|
||||
request('/user/logout')
|
||||
Scripts.login()
|
||||
it 'should fail if user is not author' do
|
||||
ticket = $database.getRow('ticket', 1, 'id')
|
||||
result = request('/ticket/seen', {
|
||||
ticketNumber: ticket['ticket_number'],
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token
|
||||
})
|
||||
|
||||
(result['status']).should.equal('fail')
|
||||
(result['message']).should.equal('NO_PERMISSION')
|
||||
end
|
||||
|
||||
request('/user/logout')
|
||||
Scripts.login('user_get@os4.com', 'user_get')
|
||||
|
|
|
@ -41,7 +41,7 @@ describe '/user/login' do
|
|||
})
|
||||
|
||||
(result['status']).should.equal('success')
|
||||
(result['data']['staff']).should.equal('true')
|
||||
(result['data']['staff']).should.equal(true)
|
||||
end
|
||||
|
||||
it 'should work with remember token' do
|
||||
|
|
Loading…
Reference in New Issue