Git Product home page Git Product logo

user-registration's People

Stargazers

Mehmet Akif DERE avatar Arvind Dangar avatar  avatar Hariom Palkar avatar  avatar De Zheng avatar Bradley Jackson avatar Likhit Garimella avatar Shahriar Kabir Khan avatar  avatar copter.js avatar  avatar GoGadgetGal avatar LambChop avatar Red avatar Jon Exume avatar Hamoud Alhoqbani avatar Adrian Edwards avatar travelerX avatar Mohammed Abunada avatar Binyam Teklu avatar AEK avatar Moonvader avatar

Watchers

 avatar James Cloos avatar

user-registration's Issues

AppDelegate, if accestoken is not nil problem

Hi Sergey,

When I try to let the application check if the accestoken is not nil and then go to the 'protected' view controller nothing is happening.

This is my Appdelegate:

`
//
// AppDelegate.swift
// Tempi
//
// Created by Robert Sprenkels on 29/03/2020.
// Copyright © 2020 Robert Sprenkels. All rights reserved.
//

import UIKit
import SwiftKeychainWrapper

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    
    let accessToken: String? = KeychainWrapper.standard.string(forKey: "accessToken")
           
           if accessToken != nil {
             let mainStoryboard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
             let homePage = mainStoryboard.instantiateViewController(identifier: "UITabBarController") as! UITabBarController
         //UITabBarController
             self.window?.rootViewController = homePage
             
        //   self.performSegue(withIdentifier: "ToSignIn", sender: "Any.")
                                     
           }
    
    return true
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
    // Called when a new scene session is being created.
    // Use this method to select a configuration to create the new scene with.
    return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
    // Called when the user discards a scene session.
    // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
    // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}

}

`

I Gues something has changed over the years, the way that swift handles this action but I can't find what it is. Can you help me out?

The accessToken is working just fine and is not nil.

Not loading next view controller

Hi Sergey,

I continued with your tutorial and now at the end of https://www.youtube.com/watch?v=qNqD-YJZV2M&list=PLdW9lrB9HDw3bMSHtNZNt1Qb9XTMmQzLU&index=11

I came to this piece of code

 print("everything fine")
                            let homePage = self.storyboard?.instantiateViewController(withIdentifier: "UITabBarController") as! UITabBarController
                            let appDelegate = UIApplication.shared.delegate
                            appDelegate?.window??.rootViewController = homePage
                            

Output:
Sign in button Tapped Access token: BIEM everything fine
So everything is working (including my web service this time :) ), but it's not opening the next view controller. (tab bar controller in this example). I also tried to open a different view controller and I'm sure it has the right identifier.
Is this something which has changed over the years in Swift 4?

Error while signing up.

Hi!

First of all, thank you very much for the great content you make!

I had to write a php json web service to be able to run in on my server. but it gives me the following error which I don't understand:

Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

PHP states: [Tue Mar 31 17:05:18.146020 2020] [core:error] [pid 864871:tid 140039761164032] [client 94.210.205.184:49849] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

Can you help ?
signupviewcontroller.swift:

`
import UIKit

class SignUpViewController: UIViewController {

@IBOutlet weak var FirstNameTextField: UITextField!
@IBOutlet weak var LastNameTextField: UITextField!
@IBOutlet weak var EmailTextField: UITextField!
@IBOutlet weak var PasswordTextField: UITextField!
@IBOutlet weak var RepeatTextField: UITextField!



override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
}


@IBAction func SignUpButtonTapped(_ sender: Any) {
    print("Sign Up Button Tapped")
     
    if  FirstNameTextField.text!.isEmpty ||
        LastNameTextField.text!.isEmpty ||
        EmailTextField.text!.isEmpty ||
        PasswordTextField.text!.isEmpty ||
        RepeatTextField.text!.isEmpty
        
    { //(Then) display allert message and return
        displayMessage(userMessage: "Fill in all fields")
        return
    }

    // Validate passowrd
    if ((PasswordTextField.text?.elementsEqual(RepeatTextField.text!)) != true)
    {
        //(Then, alert message and return
        displayMessage(userMessage: "Passwords don't match")
        return
    }
    
    //Create Activity indicator
        let myActivityIndicator = UIActivityIndicatorView(style:UIActivityIndicatorView.Style.medium)
    // Position activity indicator in ithe center of the main view
    myActivityIndicator.center = view.center
    
    //If needed, you can prevent actitivty indicator from hiding when stopAnimating() is calles
    myActivityIndicator.hidesWhenStopped = false
    
    //Start activity indicator
    myActivityIndicator.startAnimating()
    view.addSubview(myActivityIndicator)
    
    //http request to register user
       let myUrl = URL(string: "*****Blanked out**********/create.php") //**Https** url
    
 var request = URLRequest(url:myUrl!)
               request.httpMethod = "POST"// Compose a query string
               request.addValue("application/json", forHTTPHeaderField: "content-type")
               request.addValue("application/json", forHTTPHeaderField: "Accept")
               
    let postString = [ "UID": "",                                 "firstName": FirstNameTextField.text!,
                                    "lastName": LastNameTextField.text!,
                                    "userName": EmailTextField.text!,
                                    "userPassword": PasswordTextField.text!,
                                  ] as [String: String]
             print(postString)
               do {
                   request.httpBody = try JSONSerialization.data(withJSONObject: postString, options: .prettyPrinted)
                print(JSONSerialization.data)
               } catch let error {
                   print(error.localizedDescription)
                   displayMessage(userMessage: "Something went wrong. Try again.")
                   return
               }
               
            let task = URLSession.shared.dataTask(with: request) { (data: Data?, response: URLResponse?, error: Error?) in
               
               self.removeActivityIndicator(activityIndicator: myActivityIndicator)
               
               if error != nil
               {
                   self.displayMessage(userMessage: "Could not successfully perform this request. Please try again later")
                   print("error=\(String(describing: error))")
                   return
               }
               
               
               //Let's convert response sent from a server side code to a NSDictionary object:
               do {
                let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary
                   
                   if let parseJSON = json {
                       
                       
                       let userId = parseJSON["uid"] as? String
                       print("User id: \(String(describing: userId!))")
                       
                       if (userId?.isEmpty)!
                       {
                           // Display an Alert dialog with a friendly error message
                           self.displayMessage(userMessage: "Could not successfully perform this request. Please try again later ofzo")
                           return
                       } else {
                           self.displayMessage(userMessage: "Successfully Registered a New Account. Please proceed to Sign in")
                       }
                       
                   } else {
                       //Display an Alert dialog with a friendly error message
                       self.displayMessage(userMessage: "Could not successfully perform this request. Please try again later ofzo 1")
                   }
               } catch {
                   
                   self.removeActivityIndicator(activityIndicator: myActivityIndicator)
                   
                   // Display an Alert dialog with a friendly error message
                   self.displayMessage(userMessage: "Could not successfully perform this request. Please try again later ofzo 2")
                   print(error)
               }
               }
               
               task.resume()
               
           }
           
               
               
             func removeActivityIndicator(activityIndicator: UIActivityIndicatorView)
               {
                   DispatchQueue.main.async
                    {
                           activityIndicator.stopAnimating()
                           activityIndicator.removeFromSuperview()
                   }
               }
               
           
           func displayMessage(userMessage:String) -> Void {
               DispatchQueue.main.async
                   {
                       let alertController = UIAlertController(title: "Alert", message: userMessage, preferredStyle: .alert)
                       
                       let OKAction = UIAlertAction(title: "OK", style: .default) { (action:UIAlertAction!) in
                           // Code in this block will trigger when OK button tapped.
                           print("Ok button tapped")
                           DispatchQueue.main.async
                               {
                                  // self.dismiss(animated: true, completion: nil)
                           }
                       }
                       alertController.addAction(OKAction)
                       self.present(alertController, animated: true, completion:nil)
               }
           }
        

       }

`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.