Exemplo n.º 1
0
        public XmlLocalizationStore GetXmlLocalizationStore(string langCode)
        {
            if (String.IsNullOrEmpty(langCode))
            {
                throw new UnsupportedLanguageException();
            }


            XmlLocalizationStore store;

            if (cache.TryGetValue(langCode, out store))
            {
                return(store);
            }

            if (!LangCodes.Contains(langCode))
            {
                throw new UnsupportedLanguageException();
            }

            store = new XmlLocalizationStore(langCode, Path, providers)
            {
                Logger = Logger
            };

            lock (cache)
            {
                cache[langCode] = store;
            }

            return(store);
        }
Exemplo n.º 2
0
 public AccountController(IRepository <User> userRepository, LangCodes langCodes,
                          IProfilePicRepository picRepository, IAuthTokenService <JwtBody> tokenService)
 {
     this.userRepository = userRepository;
     this.picRepository  = picRepository;
     this.tokenService   = tokenService;
     this.langCodes      = langCodes;
 }
Exemplo n.º 3
0
        public async Task <JsonResult> Register([FromBody] RegistrationModel registrationModel,
                                                [FromServices] LangCodes langCodes)
        {
            Console.WriteLine(registrationModel == null);
            User user = await userRepository
                        .Find(u => u.displayName == registrationModel.displayName);

            if (user != null)
            {
                return(Json(new BaseResponse(false, "Name is already taken")));
            }

            user = new User
            {
                displayName   = registrationModel.displayName,
                passwordHash  = registrationModel.passHash,
                language      = "English",
                langCode      = "en",
                firebaseToken = registrationModel.firebaseToken
            };

            await userRepository.Insert(user);

            string token = tokenService.Issue(new JwtBody
            {
                issuedAt = (DateTime.UtcNow.Subtract(
                                new System.DateTime(1970, 1, 1))).TotalSeconds.ToString(),
                id          = user.Id.ToString(),
                displayName = user.displayName,
                langCode    = user.langCode
            });

            return(Json(new TokenResponse
            {
                succeeded = true,
                token = token,
            }));
        }