Skip to content

Conversation

@tungntEmotiv
Copy link
Contributor

The PR to implement AuthService include:

  • introduce new class for new API responsible for init and authorization
  • move corresponding logic from EmotivUnityItf, Authorizer to AuthService

Please help to review. Thanks

PermissionsDenied = 2,
WebSocketConnectFailed = 3,
AccessRightDenied = 4,
AuthorizationFailed = 5,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would like to hide things related to web socket to simply the API, so can we hide these 3 error codes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think can hide the WebSocketConnectFailed or replace by Unknown Error, for embedded lib, the connection always work , but the AccessRightDenied still need for this version, because cause UI wait the error code to open the eula terms popup, i think i can rename to NoAccessRight for better

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's no harm if we ignore this step. The app which logins always has access right and we're sure about that inside Cortex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added some comment for the error code, i think we can keep some errorcode for logic of if else even the error occur rarely

public enum CortexErrorCode
{
OK = 0,
PermissionsDenied = 2, // Indicates that the requested operation failed because the required permissions were not granted.
Copy link
Collaborator

Choose a reason for hiding this comment

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

PermissionsDenied = 1 (not 2)?

public enum CortexErrorCode
{
OK = 0,
PermissionsDenied = 2, // Indicates that the requested operation failed because the required permissions were not granted.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this explanation for the error is not clear enough to help developers understand.

OK = 0,
PermissionsDenied = 2, // Indicates that the requested operation failed because the required permissions were not granted.
CortexConnectionError = 3, // Indicates that the connection to Cortex started unsuccessfully.
NoEULAAccepted = 4, // Indicates that the user has not accepted the End User License Agreement (EULA). Only for Cortex v3. Must be removed at Cortex v5
Copy link
Collaborator

Choose a reason for hiding this comment

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

AuthorizationFailed and a boolean acceptedEula in UserInfo.

using Emotiv.Cortex.Models;
using EmotivUnityPlugin; // TODO (Tung Nguyen): remove this line when move all old code to new SDK

namespace Emotiv.Cortex.Service
Copy link
Collaborator

Choose a reason for hiding this comment

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

In C#, namespace and folder structure are mirror, should we move IAuthService.cs and AuthService.cs files out of Auth folder?

{
public static class ServiceFactory
{
public static IAuthService GetAuthService()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should write a method "CreateAuthService()" instead.

public static IAuthService CreateAuthService()
{
     return new AuthService();
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

can we move these old files like Authorizer.cs into folder like __Internals__?

{
public class AuthService : IAuthService
{
public static AuthService Instance { get; } = new AuthService();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need AuthService to be singleton? I think, as a SDK, we shouldn't decide if this class is a singleton or not, it should be decided by the application.

{
OK = 0,
PermissionsDenied = 2, // Indicates that the requested operation failed because the required permissions were not granted.
CortexConnectionError = 3, // Indicates that the connection to Cortex started unsuccessfully.
Copy link
Collaborator

Choose a reason for hiding this comment

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

UnknownError?

PermissionsDenied = 2, // Indicates that the requested operation failed because the required permissions were not granted.
CortexConnectionError = 3, // Indicates that the connection to Cortex started unsuccessfully.
NoEULAAccepted = 4, // Indicates that the user has not accepted the End User License Agreement (EULA). Only for Cortex v3. Must be removed at Cortex v5
AuthorizationFailed = 5, // Indicates that the authorization process failed overall.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thinking...


namespace Emotiv.Cortex.Service
{
public interface IAuthService
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about the case when client id / secret is empty or invalid?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants